hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588
values | lang stringclasses 305
values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9c126a7dde4a8ed10ffccd70729fa47be38f8e31 | 1,753 | h | C | TitaniumRose/src/TitaniumRose/ComponentSystem/GameObject.h | Zinadore/Hazel-D3D12 | 084cf9a473b6c66a2890f107667f687d6c7ed0a0 | [
"Apache-2.0"
] | null | null | null | TitaniumRose/src/TitaniumRose/ComponentSystem/GameObject.h | Zinadore/Hazel-D3D12 | 084cf9a473b6c66a2890f107667f687d6c7ed0a0 | [
"Apache-2.0"
] | null | null | null | TitaniumRose/src/TitaniumRose/ComponentSystem/GameObject.h | Zinadore/Hazel-D3D12 | 084cf9a473b6c66a2890f107667f687d6c7ed0a0 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "TitaniumRose/ComponentSystem/Transform.h"
#include "TitaniumRose/Core/Core.h"
#include "TitaniumRose/ComponentSystem/HMesh.h"
#include "TitaniumRose/ComponentSystem/Component.h"
#include "TitaniumRose/Renderer/Material.h"
#include "TitaniumRose/Renderer/Vertex.h"
#include "Platform/D3D12/D3D12Buffer.h"
#include "Platform/D3D12/D3D12Texture.h"
#include <vector>
#include <string>
namespace Roses {
struct DecoupledTextureComponent
{
bool UseDecoupledTexture = false;
bool OverwriteRefreshRate = false;
uint64_t LastFrameUpdated = 0;
uint64_t UpdateFrequency = 1;
Ref<VirtualTexture2D> VirtualTexture = nullptr;
};
class HGameObject
{
public:
~HGameObject()
{
}
HTransform Transform;
Roses::Ref<HMesh> Mesh;
Roses::Ref<HMaterial> Material;
DecoupledTextureComponent DecoupledComponent;
std::vector<Roses::Ref<Roses::HGameObject>> children;
void AddChild(Roses::Ref<Roses::HGameObject> child) {
if (child.get() == this || child == nullptr)
return;
children.push_back(child);
child->SetParent(this);
}
void Update(Timestep ts);
std::vector<Ref<Component>> Components;
template <typename TComponent,
typename = std::enable_if_t<std::is_base_of_v<Roses::Component, TComponent>>>
Ref<TComponent> AddComponent()
{
auto component = CreateRef<TComponent>();
component->gameObject = this;
Components.emplace_back(component);
return component;
}
std::string Name;
uint32_t ID = -1;
private:
HGameObject* m_Parent = nullptr;
void SetParent(HGameObject* parent) {
if (parent == this || parent == nullptr)
return;
this->Transform.SetParent(&parent->Transform);
this->m_Parent = parent;
}
};
} | 21.120482 | 80 | 0.710782 |
9c7e2601ef199d694a067f6fb1b0225501b8df09 | 1,778 | h | C | third_party/swiot/swiot_devicefind.h | mingxin891018/ESP8266_RTOS_SDK-2.0.0 | a5a1f740e26ab81ac5e571f00c263e6cf976099e | [
"BSD-3-Clause"
] | null | null | null | third_party/swiot/swiot_devicefind.h | mingxin891018/ESP8266_RTOS_SDK-2.0.0 | a5a1f740e26ab81ac5e571f00c263e6cf976099e | [
"BSD-3-Clause"
] | null | null | null | third_party/swiot/swiot_devicefind.h | mingxin891018/ESP8266_RTOS_SDK-2.0.0 | a5a1f740e26ab81ac5e571f00c263e6cf976099e | [
"BSD-3-Clause"
] | null | null | null | #ifndef __SWIOT_DEVICEFIND_H__
#define __SWIOT_DEVICEFIND_H__
#include "esp_common.h"
#include "espconn.h"
#define MAX_ENTRY_NAME_SIZE 16
#define MAX_ENTRY_VALUE_SIZE 256
#define SWIOT_REQ "swiot_req"
#define SWIOT_REQ_VALUE "1"
#define SWIOT_DEVID "swiot_devid"
#define SWIOT_CONNECT_INFO "connect_info"
#define SWIOT_STATUS "swiot_status"
#define SWIOT_FIN "fin"
#define UDP_SEND_COUNT_MAX 5
#define MAX_BUFFER_SIZE 2048
#define RESEND_TIME_INTERVAL 2*1000 // 2 s
typedef struct entry_set_t{
char name[MAX_ENTRY_NAME_SIZE];
char value[MAX_ENTRY_VALUE_SIZE];
}entry_set;
typedef enum connet_status_t {
CONNECT_NULL = 0,
CONNECT_WAIT_REQ,
CONNECT_REQ,
CONNECT_SEND_DEVID,
CONNECT_RECV_CON_INFO,
CONNECT_CON_WAIT,
CONNECT_FIN,
CONNECT_MAX
}connet_status_em;
typedef enum core_status_t {
CORE_CONNECT_FAILED = -1,
CORE_CONNECTING = 0,
CORE_CONNECT_SUCCESS = 1,
}core_status_em;
typedef void (*connect_info_cb)(char* connect_info);
typedef struct device_find_ct_t{
int32_t port;
connect_info_cb connect_cb;
char device_sn[MAX_ENTRY_VALUE_SIZE];
char product_key[MAX_ENTRY_NAME_SIZE];
int32_t status;
struct espconn conn;
esp_udp conn_udp;
int32_t udp_send_count;
int32_t next_send_time;
char buf[MAX_BUFFER_SIZE];
char buf_len;
int32_t connect_status;
} device_find_ct;
int32_t device_find_init(int32_t port, char* product_key, char* device_sn, connect_info_cb connect_cb);
int32_t device_find_ontime();
/**
* @parma core_status 设置core连接状态
**/
void device_find_set_core_status( core_status_em core_status );
void device_find_deinit();
int32_t device_get_status();
#endif
| 21.682927 | 103 | 0.732846 |
84394c0c31efda166c859be645905c16736d6ea3 | 3,214 | h | C | array.h | t6/libias | 45a6bbb189f00121a6e6374fc543b7d62915aea1 | [
"BSD-2-Clause"
] | 1 | 2021-02-27T16:48:51.000Z | 2021-02-27T16:48:51.000Z | array.h | t6/libias | 45a6bbb189f00121a6e6374fc543b7d62915aea1 | [
"BSD-2-Clause"
] | null | null | null | array.h | t6/libias | 45a6bbb189f00121a6e6374fc543b7d62915aea1 | [
"BSD-2-Clause"
] | null | null | null | /*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2019 Tobias Kortkamp <tobik@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#pragma once
struct Array;
struct ArrayIterator;
struct diff;
struct Mempool;
typedef int (*ArrayCompareFn)(const void *, const void *, void *);
struct Array *array_new(void);
struct Array *array_from_array(const void *[], size_t);
void array_append(struct Array *, const void *);
struct diff *array_diff(struct Array *, struct Array *, struct Mempool *, ArrayCompareFn, void *);
void array_free(struct Array *);
void *array_get(struct Array *, size_t);
ssize_t array_find(struct Array *, const void *, ArrayCompareFn, void *);
void array_insert(struct Array *, size_t, const void *);
void *array_remove(struct Array *, size_t);
void array_join(struct Array *, struct Array *[], size_t);
size_t array_len(struct Array *);
void *array_pop(struct Array *);
void array_set(struct Array *, size_t, const void *);
void array_sort(struct Array *, ArrayCompareFn, void *);
void array_truncate(struct Array *);
void array_truncate_at(struct Array *array, size_t);
struct ArrayIterator *array_iterator(struct Array *, ssize_t, ssize_t);
void array_iterator_cleanup(struct ArrayIterator **);
bool array_iterator_next(struct ArrayIterator **, size_t *, void **, void **);
#define ARRAY(...) \
array_from_array((const void *[]){__VA_ARGS__}, sizeof((const void *[]){__VA_ARGS__})/sizeof(const void *))
#define ARRAY_JOIN(ARRAY, ...) __ARRAY_JOIN(ARRAY, GENSYM(__array_join__), __VA_ARGS__)
#define __ARRAY_JOIN(ARRAY, ARRAYS, ...) do { \
struct Array *ARRAYS[] = { __VA_ARGS__ }; \
array_join(ARRAY, ARRAYS, nitems(ARRAYS)); \
} while(0);
#define ARRAY_FOREACH_SLICE(ARRAY, A, B, TYPE, VAR) \
ITERATOR_FOREACH(Array, array, ARRAY, A, B, TYPE, void **, VAR, NULL, void *, void **, GENSYM(VAR), NULL)
#define ARRAY_FOREACH(ARRAY, TYPE, VAR) \
ARRAY_FOREACH_SLICE(ARRAY, 0, -1, TYPE, VAR)
| 45.914286 | 108 | 0.744244 |
573d78fd06fe2e3f4148f382271b90eba168efb3 | 234 | h | C | Health.h | DonnieDonowitz/ShootingGame | da2f802181ffaf86d7e79ca0b3446699b727120a | [
"MIT"
] | null | null | null | Health.h | DonnieDonowitz/ShootingGame | da2f802181ffaf86d7e79ca0b3446699b727120a | [
"MIT"
] | null | null | null | Health.h | DonnieDonowitz/ShootingGame | da2f802181ffaf86d7e79ca0b3446699b727120a | [
"MIT"
] | null | null | null | #pragma once
#include <QGraphicsTextItem>
class Health : public QGraphicsTextItem
{
Q_OBJECT
public:
Health(QGraphicsItem *parent = 0);
void decrease();
int getHealth();
private:
int health;
};
| 13.764706 | 40 | 0.632479 |
3bf36ce9bce416775135d58e4c2bcb1792f0315b | 11,624 | h | C | starter-stack/Lib/rcsc/player/body_sensor.h | InsperDynamics/Soccer-Simulation-2D | a548d576ca4ab2a8f797810f5e23875c45cef73f | [
"Apache-2.0"
] | null | null | null | starter-stack/Lib/rcsc/player/body_sensor.h | InsperDynamics/Soccer-Simulation-2D | a548d576ca4ab2a8f797810f5e23875c45cef73f | [
"Apache-2.0"
] | null | null | null | starter-stack/Lib/rcsc/player/body_sensor.h | InsperDynamics/Soccer-Simulation-2D | a548d576ca4ab2a8f797810f5e23875c45cef73f | [
"Apache-2.0"
] | null | null | null | // -*-c++-*-
/*!
\file body_sensor.h
\brief sense_body sensor Header File
*/
/*
*Copyright:
Copyright (C) Hidehisa AKIYAMA
This code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*EndCopyright:
*/
/////////////////////////////////////////////////////////////////////
#ifndef RCSC_PLAYER_BODY_SENSOR_H
#define RCSC_PLAYER_BODY_SENSOR_H
#include <rcsc/player/view_mode.h>
#include <rcsc/game_time.h>
#include <rcsc/types.h>
#include <iostream>
namespace rcsc {
/*!
\class BodySensor
\brief sense_body info holder
*/
class BodySensor {
public:
GameTime M_time; //!< updated game time
ViewQuality M_view_quality; //!< sensed view quality
ViewWidth M_view_width; //!< sensed view width
double M_stamina; //!< sensed stamina value
double M_effort; //!< sensed effort value
double M_stamina_capacity; //!< sensed stamina capacity
double M_speed_mag; //!< sensed speed magnitude. this is quantized by 0.01.
double M_speed_dir_relative; //!< speed dir. this is relative to face angle.
double M_neck_relative; //!< neck angle. this is relative to body angle
int M_kick_count; //!< sensed command count
int M_dash_count; //!< sensed command count
int M_turn_count; //!< sensed command count
int M_say_count; //!< sensed command count
int M_turn_neck_count; //!< sensed command count
int M_catch_count; //!< sensed command count
int M_move_count; //!< sensed command count
int M_change_view_count; //!< sensed command count
/*!
the number of cycles till the arm is movable.
if 0, arm is movable now
*/
int M_arm_movable;
/*!
the number of cycles till the arm stops pointing.
if 0, player is not pointing.
*/
int M_arm_expires;
/*!
the distance of the point the player is pointing to, relative to the
player's position, accurate to 10cm
*/
double M_pointto_dist;
/*!
the direction of the point the player is pointing to, relative to the
player's face angle, accurate to 0.1 deg.
*/
double M_pointto_dir;
int M_pointto_count; //!< sensed command count
SideID M_attentionto_side; //!< attended side
int M_attentionto_unum; //!< attended player number
int M_attentionto_count; //!< sensed command count
/*!
the number of cycles the current tackle will last for.
if 0, player is not tackling.
*/
int M_tackle_expires; //!< tackle expire cycles
int M_tackle_count; //!< sensed command count1
bool M_none_collided; //!< true if 'none' collides
bool M_ball_collided; //!< ball collision info
bool M_player_collided; //!< player collision info
bool M_post_collided; //!< post collision info
int M_charged_expires; //!< foul charged expire cycle
Card M_card; //!< yellow/red card
public:
/*!
\brief init member variables
*/
BodySensor();
/*!
\brief analyze server message
\param msg raw server message
\param version client version
\param current current game time
*/
void parse( const char * msg,
const double & version,
const GameTime & current )
{
parse1( msg, version, current );
}
/*!
\brief analyze server message usind very ugly style but very fast
\param msg server message
\param version client version
\param current current game time
*/
void parse1( const char * msg,
const double & version,
const GameTime & current );
/*!
\brief analyze server message using std::sscanf.
\param msg server message
\param version client version
\param current current game time
*/
void parse2( const char * msg,
const double & version,
const GameTime & current );
private:
/*!
\brief analyze collision information contained by sense_body message.
\param msg server message started with (collision
\param pointer pointer to the next character after parsing
\return parsing result
*/
bool parseCollision( const char * msg,
char ** next );
/*!
\brief analyze card information
\param msg server message started with (card
\param pointer pointer to the next character after parsing
\return parsing result
*/
bool parseFoul( const char * msg,
char ** next );
public:
/*!
\brief get last updated time
\return const reference to the game time
*/
const
GameTime & time() const
{
return M_time;
}
/*!
\brief get analyzed view quality
\return const reference to the view quality object
*/
const
ViewQuality & viewQuality() const
{
return M_view_quality;
}
/*!
\brief get analyzed view width
\return const reference to the view width object
*/
const
ViewWidth & viewWidth() const
{
return M_view_width;
}
/*!
\brief get analyzed stamina value
\return stamina value
*/
const
double & stamina() const
{
return M_stamina;
}
/*!
\brief get analyzed effort
\return effort value
*/
const
double & effort() const
{
return M_effort;
}
/*!
\brief get analized stamina capacity value
\return stamina capacity value
*/
const
double & staminaCapacity() const
{
return M_stamina_capacity;
}
/*!
\brief get analyzed speed value
\return scalar value of velocity
*/
const
double & speedMag() const
{
return M_speed_mag;
}
/*!
\brief get analyzed velocity direction relative to player's face direction
\return velocity direction
*/
const
double & speedDir() const
{
return M_speed_dir_relative;
}
/*!
\brief get analyzed neck angle
\return neck angle value
*/
const
double & neckDir() const
{
return M_neck_relative;
}
/*!
\brief get analyzed kick count
\return count of performed kick command
*/
int kickCount() const
{
return M_kick_count;
}
/*!
\brief get analyzed dash count
\return count of performed kick command
*/
int dashCount() const
{
return M_dash_count;
}
/*!
\brief get analyzed turn count
\return count of performed turn command
*/
int turnCount() const
{
return M_turn_count;
}
/*!
\brief get analyzed say count
\return count of performed say command
*/
int sayCount() const
{
return M_say_count;
}
/*!
\brief get analyzed turn_neck count
\return count of performed turn_neck command
*/
int turnNeckCount() const
{
return M_turn_neck_count;
}
/*!
\brief get analyzed catch count
\return count of performed catch command
*/
int catchCount() const
{
return M_catch_count;
}
/*!
\brief get analyzed move count
\return count of performed move command
*/
int moveCount() const
{
return M_move_count;
}
/*!
\brief get analyzed change_view count
\return count of performed change_view command
*/
int changeViewCount() const
{
return M_change_view_count;
}
/*!
\brief get analyzed cycles till the arm is movable
\return cycles till the arm is movable
*/
int armMovable() const
{
return M_arm_movable;
}
/*!
\brief get analyzed cycles till the arm stops pointing
\return cycles till the arm is movable
*/
int armExpires() const
{
return M_arm_expires;
}
/*!
\brief get analyzed distance to the point that player is pointing
\return distance value
*/
const
double & pointtoDist() const
{
return M_pointto_dist;
}
/*!
\brief get analyzed direction relative to player's face
\return direction value
*/
const
double & pointtoDir() const
{
return M_pointto_dir;
}
/*!
\brief get analyzed pointto count
\return count of performed pointto command
*/
int pointtoCount() const
{
return M_pointto_count;
}
/*!
\brief get analyzed attended player's side
\return side Id
*/
SideID attentiontoSide() const
{
return M_attentionto_side;
}
/*!
\brief get analyzed attended player's uniform number
\return uniform number
*/
int attentiontoUnum() const
{
return M_attentionto_unum;
}
/*!
\brief get analyzed attentionto count
\return count of performed attentionto command
*/
int attentiontoCount() const
{
return M_attentionto_count;
}
/*!
\brief get analyzed cycles the current tackle will last for
\return cycles till tackle is exired
*/
int tackleExpires() const
{
return M_tackle_expires;
}
/*!
\brief get analyzed tackle count
\return count of performed tackle command
*/
int tackleCount() const
{
return M_tackle_count;
}
/*!
\brief get the information wheter the agent receive does not collide.
\return true if this body sensor has 'none' collision information.
*/
bool noneCollided() const
{
return M_none_collided;
}
/*!
\brief get the information wheter the agent collides with ball
\return true if the agent collides with ball.
*/
bool ballCollided() const
{
return M_ball_collided;
}
/*!
\brief get the information wheter the agent collides with player
\return true if the agent collides with player.
*/
bool playerCollided() const
{
return M_player_collided;
}
/*!
\brief get the information wheter the agent collides with posts
\return true if the agent collides with posts.
*/
bool postCollided() const
{
return M_post_collided;
}
/*!
\brief get expire cycle of foul charge
\return expire cycle of foul charge
*/
int chargedExpires() const
{
return M_charged_expires;
}
/*!
\brief get the yellow/red card status
\return card type
*/
Card card() const
{
return M_card;
}
/*!
\brief put data to output stream
\param os reference to the output stream
\return reference to the output stream
*/
std::ostream & print( std::ostream & os ) const;
};
}
#endif
| 23.578093 | 80 | 0.604439 |
7e86be6f524b25045a9fa6c02664650e93e338a1 | 3,238 | h | C | Motion/Processing/State_Control/c_motion_state_control.h | shooter64738/Talos-PMC | 370d34363e23ec46109f3f0737be60e4e6013832 | [
"MIT"
] | null | null | null | Motion/Processing/State_Control/c_motion_state_control.h | shooter64738/Talos-PMC | 370d34363e23ec46109f3f0737be60e4e6013832 | [
"MIT"
] | null | null | null | Motion/Processing/State_Control/c_motion_state_control.h | shooter64738/Talos-PMC | 370d34363e23ec46109f3f0737be60e4e6013832 | [
"MIT"
] | null | null | null | #ifndef __C_MOTION_CORE_STATE_CONTROLLER_H
#define __C_MOTION_CORE_STATE_CONTROLLER_H
#include <stdint.h>
#include "../../../physical_machine_parameters.h"
#include "../../../_bit_flag_control.h"
#include "../../Core/support_items/s_complete_block_stats.h"
/*
All control flags for motion are in here. If its a flag that has something to do with the motion
it is controlled by flags in here. If I find a missed flag I move it to here. I want a central
location to control all motion output from.
*/
namespace Talos
{
namespace Motion
{
namespace Core
{
namespace States
{
enum class e_state_class :uint32_t
{
Motion = 0,
Process = 1,
Output = 2,
};
extern void execute();
extern void execute(e_state_class st_class);
class Process
{
//variables
public:
enum class e_states :uint32_t
{
decel_override = 0,
ngc_buffer_not_empty = 1,
ngc_buffer_empty = 2,
motion_buffer_not_empty = 3,
motion_buffer_full = 4,
ngc_block_has_no_motion = 5,
};
static s_bit_flag_controller_32<e_states> states;
protected:
private:
//functions
public:
static void execute();
protected:
private:
static void __load_ngc();
static void __load_segments();
};
class Motion
{
//variables
public:
enum class e_states :uint32_t
{
ready = 0,
hold = 1,
terminate = 2,
running = 3,
reset =4,
//wait_for_spindle_at_speed = 4,
//spindle_at_speed = 5,
//spindle_on = 6,
//spindle_off = 7,
hard_fault = 5,
spindle_failure = 6,
//motion_on = 10,
//motion_off = 11,
auto_cycle_start = 7,
cycle_start = 8,
};
static s_bit_flag_controller_32<e_states> states;
protected:
private:
enum class e_internal_states :uint32_t
{
held = 0,
release = 1,
};
static s_bit_flag_controller_32<e_internal_states> __internal_states;
static uint32_t spindle_request_time;
//functions
public:
static void execute();
protected:
private:
static void __run();
static void __reset_motion_states();
static void __cycle_start();
static void __cycle_hold();
static void __cycle_release();
static void __cycle_reset();
static void __config_spindle();
};
class Output
{
//variables
public:
enum class e_states :uint32_t
{
spindle_requested_on = 0,
spindle_requested_off = 1,
spindle_get_speed = 2,
hardware_fault = 3,
interpolation_running = 4,
interpolation_complete = 5,
ngc_block_done = 6,
};
static s_bit_flag_controller_32<e_states> states;
static int32_t spindle_last_checked_speed;
static int32_t spindle_target_speed;
static s_complete_block_stats block_stats;
protected:
private:
//functions
public:
static void execute();
protected:
private:
static void __motion_on();
static void __motion_off();
static void __spindle_on();
static void __spindle_off();
static int32_t __spindle_speed();
};
};
};
};
};
#endif | 20.890323 | 96 | 0.632798 |
cc337b7a9bde820c8fc1be47b645777e5e349550 | 2,110 | c | C | code/sources/orion/uniform.c | Gentil-N/arcade-toolkit | 6a6a6d11d01e501cd09a53be0ca575068521976c | [
"MIT"
] | null | null | null | code/sources/orion/uniform.c | Gentil-N/arcade-toolkit | 6a6a6d11d01e501cd09a53be0ca575068521976c | [
"MIT"
] | null | null | null | code/sources/orion/uniform.c | Gentil-N/arcade-toolkit | 6a6a6d11d01e501cd09a53be0ca575068521976c | [
"MIT"
] | null | null | null | #include "orn_core.h"
OrnUniform *ornCreateUniform(OrnDevice *device, const OrnUniformSettings *settings)
{
OrnUniform *uniform = (OrnUniform *)atk_alloc(sizeof(struct OrnUniform));
atk_api_assert(uniform != NULL);
VkDescriptorSetAllocateInfo descriptor_alloc_info = vkfDescriptorSetAllocateInfo(
settings->pipeline->descriptor_pool, 1, &atk_get(VkDescriptorSetLayout, settings->pipeline->descriptor_set_layouts, settings->set));
orn_assert_vk(device->tbl.vkAllocateDescriptorSets(device->handle, &descriptor_alloc_info, &uniform->descriptor_set));
uniform->set = settings->set;
atk_api_dbg_info("uniform created");
return uniform;
}
void ornDestroyUniform(OrnDevice *device, OrnPipeline *pipeline, OrnUniform *uniform)
{
device->tbl.vkFreeDescriptorSets(device->handle, pipeline->descriptor_pool, 1, &uniform->descriptor_set);
atk_free(uniform);
atk_api_dbg_info("descriptor sets released");
}
void ornLinkBufferToUniform(OrnDevice *device, OrnUniform *uniform, OrnBuffer *buffer, size_t offset, size_t size, uint32_t binding)
{
VkDescriptorBufferInfo buffer_info = vkfDescriptorBufferInfo(buffer->handle, offset, size);
VkWriteDescriptorSet write_desc_set = vkfWriteDescriptorSet(
uniform->descriptor_set, binding, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, NULL, &buffer_info, NULL);
device->tbl.vkUpdateDescriptorSets(device->handle, 1, &write_desc_set, 0, NULL);
atk_api_dbg_info("buffer linked to descriptor");
}
void ornLinkTextureToUniform(OrnDevice *device, OrnUniform *uniform, OrnTexture *texture, uint32_t binding)
{
VkDescriptorImageInfo image_info = vkfDescriptorImageInfo(texture->sampler, texture->image_view, texture->layout);
VkWriteDescriptorSet write_desc_set = vkfWriteDescriptorSet(
uniform->descriptor_set, binding, 0, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, &image_info, NULL, NULL);
device->tbl.vkUpdateDescriptorSets(device->handle, 1, &write_desc_set, 0, NULL);
atk_api_dbg_info("texture linked to descriptor");
} | 51.463415 | 143 | 0.755924 |
046253ad94288df7093c30e617281b5fb82ff329 | 83,318 | c | C | ImperasLib/source/renesas.ovpworld.org/processor/v850/1.0/model/v850MorphUser.c | emanuellucas2/OVPsimProject | 6c9f5bfaaa135fa63d63746bacf5759c6d6c0e9e | [
"TCL"
] | null | null | null | ImperasLib/source/renesas.ovpworld.org/processor/v850/1.0/model/v850MorphUser.c | emanuellucas2/OVPsimProject | 6c9f5bfaaa135fa63d63746bacf5759c6d6c0e9e | [
"TCL"
] | null | null | null | ImperasLib/source/renesas.ovpworld.org/processor/v850/1.0/model/v850MorphUser.c | emanuellucas2/OVPsimProject | 6c9f5bfaaa135fa63d63746bacf5759c6d6c0e9e | [
"TCL"
] | null | null | null | /*
* Copyright (c) 2005-2021 Imperas Software Ltd., www.imperas.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "vmi/vmiMessage.h"
#include "vmi/vmiMt.h"
#include "vmi/vmiRt.h"
#include "v850BlockState.h"
#include "v850Instructions.h"
#include "v850Exceptions.h"
#include "v850Morph.h"
#include "v850MorphFP.h"
#include "v850Utils.h"
#define IMMTSREG(SREG, VALUE) { \
Uns32 mask = v850->SPR_ ## SREG ## _wmask.reg; \
Uns32 prevREG = v850->SPR_ ## SREG .reg & ~mask; \
Uns32 nextREG = VALUE & mask; \
v850->SPR_ ## SREG .reg = prevREG | nextREG; \
}
//
// Write Flag Const structures
//
static const vmiFlags flags_Si = {
VMI_NOFLAG_CONST,
{
VMI_NOFLAG_CONST,
VMI_NOFLAG_CONST,
VMI_NOFLAG_CONST,
V850_FLG_PSW_SI_CONST,
VMI_NOFLAG_CONST
}
};
static const vmiFlags flags_Zr = {
VMI_NOFLAG_CONST,
{
VMI_NOFLAG_CONST,
VMI_NOFLAG_CONST,
V850_FLG_PSW_ZR_CONST,
VMI_NOFLAG_CONST,
VMI_NOFLAG_CONST
}
};
static const vmiFlags flags_ZrSi = {
VMI_NOFLAG_CONST,
{
VMI_NOFLAG_CONST,
VMI_NOFLAG_CONST,
V850_FLG_PSW_ZR_CONST,
V850_FLG_PSW_SI_CONST,
VMI_NOFLAG_CONST
}
};
static const vmiFlags flags_ZrSiOv = {
VMI_NOFLAG_CONST,
{
VMI_NOFLAG_CONST,
VMI_NOFLAG_CONST,
V850_FLG_PSW_ZR_CONST,
V850_FLG_PSW_SI_CONST,
V850_FLG_PSW_OV_CONST
}
};
static const vmiFlags flags_CoZrSi = {
VMI_NOFLAG_CONST,
{
V850_FLG_PSW_CO_CONST,
VMI_NOFLAG_CONST,
V850_FLG_PSW_ZR_CONST,
V850_FLG_PSW_SI_CONST,
VMI_NOFLAG_CONST
}
};
static const vmiFlags flags_CoZrSiOv = {
VMI_NOFLAG_CONST,
{
V850_FLG_PSW_CO_CONST,
VMI_NOFLAG_CONST,
V850_FLG_PSW_ZR_CONST,
V850_FLG_PSW_SI_CONST,
V850_FLG_PSW_OV_CONST
}
};
//
// Update carry
//
static const vmiFlags flags_CoFromZr = {
VMI_NOFLAG_CONST, // offset to carry in flag (unused)
{
VMI_NOFLAG_CONST, // offset to carry flag (unused)
VMI_NOFLAG_CONST, // offset to parity flag (unused)
V850_FLG_PSW_CO_CONST, // offset to carry flag (writing zero value)
VMI_NOFLAG_CONST, // offset to sign flag(unused)
VMI_NOFLAG_CONST // offset to overflow flag (unused)
}
};
static const vmiFlags flags_TmpFromZr = {
VMI_NOFLAG_CONST, // offset to carry in flag (unused)
{
VMI_NOFLAG_CONST, // offset to carry flag (unused)
VMI_NOFLAG_CONST, // offset to parity flag (unused)
V850_TMP_CONST(0), // offset to Temporary flag - zero
VMI_NOFLAG_CONST, // offset to sign flag (unused)
VMI_NOFLAG_CONST // offset to overflow flag (unused)
}
};
// LCOV_EXCL_START
static void unimplemented(const char *name) {
vmiMessage("F", "MORPH_UNIMP", "Instruction %s unimplemented", name);
}
static void morphUnimplemented(const char *name) {
vmimtArgNatAddress(name);
vmimtCall((vmiCallFn)unimplemented);
vmimtExit();
}
// LCOV_EXCL_STOP
static Bool UM_PrivException(v850MorphStateP state) {
Bool UserMode = (state->v850->mode==RH850_M_USER) || (state->v850->mode==RH850_M_USER_MPU);
if (UserMode) {
// Supervisor instruction Exception
vmimtArgProcessor();
vmimtCall((vmiCallFn)v850ProcessPIE);
return True;
}
return False;
}
////////////////////////////////////////////////////////////////////////////////
// CONDITIONAL INSTRUCTION EXECUTION
////////////////////////////////////////////////////////////////////////////////
//
// For conditions, this enumeration describes the circumstances under which the
// condition is satisfied
//
typedef enum v850CondOpE {
ACO_ALWAYS, // condition always True
ACO_FALSE, // condition satisfied if flag unset
ACO_TRUE, // condition satisfied if flag set
} v850CondOp;
//
// Condition Codes
//
typedef enum v850CondE {
FLAG_V,
FLAG_C,
FLAG_Z,
FLAG_NH,
FLAG_S,
FLAG_T,
FLAG_LT,
FLAG_LE,
FLAG_NV,
FLAG_NC,
FLAG_NZ,
FLAG_H,
FLAG_NS,
FLAG_SA,
FLAG_GE,
FLAG_GT,
FLAG_LAST // KEEP LAST: for sizing
} v850Cond;
//
// For conditions, this structure describes a flag and a value for a match
//
typedef struct v850CondActionS {
vmiReg flag;
v850CondOp op;
} v850CondAction, *v850CondActionP;
//
// Emit code to prepare a conditional operation and return an v850Cond structure
// giving the offset of a flag to compare against
//
static v850CondAction emitPrepareCondition(v850Cond cond) {
const static v850CondAction condTable[FLAG_LAST] = {
[FLAG_V] = {V850_FLG_PSW_OV_CONST, ACO_TRUE }, // OF==1
[FLAG_C] = {V850_FLG_PSW_CO_CONST, ACO_TRUE }, // CF==1
[FLAG_Z] = {V850_FLG_PSW_ZR_CONST, ACO_TRUE }, // ZF==1
[FLAG_NH] = {V850_FLG_TMP_CONST, ACO_TRUE }, // (CF==1) || (ZF==1)
[FLAG_S] = {V850_FLG_PSW_SI_CONST, ACO_TRUE }, // SF==1
[FLAG_T] = {VMI_NOREG, ACO_ALWAYS}, // always true
[FLAG_LT] = {V850_FLG_TMP_CONST, ACO_TRUE }, // NF!=VF
[FLAG_LE] = {V850_FLG_TMP_CONST, ACO_TRUE }, // (ZF==1) || (NF!=VF)
[FLAG_NV] = {V850_FLG_PSW_OV_CONST, ACO_FALSE }, // OF==0
[FLAG_NC] = {V850_FLG_PSW_CO_CONST, ACO_FALSE }, // CF==0
[FLAG_NZ] = {V850_FLG_PSW_ZR_CONST, ACO_FALSE }, // ZF==0
[FLAG_H] = {V850_FLG_TMP_CONST, ACO_FALSE }, // (CF==0) && (ZF==0)
[FLAG_NS] = {V850_FLG_PSW_SI_CONST, ACO_FALSE }, // SF==0
[FLAG_SA] = {V850_FLG_PSW_SAT_CONST, ACO_TRUE }, // SAT=1
[FLAG_GE] = {V850_FLG_TMP_CONST, ACO_FALSE }, // (S xor OV) = 0
[FLAG_GT] = {V850_FLG_TMP_CONST, ACO_FALSE }, // ((S xor OV) or Z) = 0
};
// get the table entry corresponding to the instruction condition
v850CondAction entry = condTable[cond];
vmiReg tf = entry.flag;
switch(cond) {
case FLAG_T:
// unconditional execution
break;
case FLAG_V:
case FLAG_C:
case FLAG_Z:
case FLAG_S:
case FLAG_NV:
case FLAG_NC:
case FLAG_NZ:
case FLAG_NS:
case FLAG_SA:
// basic flags, always valid
break;
case FLAG_H:
case FLAG_NH:
// (Carry or Zero) = 1
vmimtBinopRRR(8, vmi_OR, tf, V850_FLG_PSW_CO_WR, V850_FLG_PSW_ZR_RD, 0);
break;
case FLAG_LT:
case FLAG_GE:
// (Sign ^ Overflow) = 1
vmimtBinopRRR(8, vmi_XOR, tf, V850_FLG_PSW_SI_WR, V850_FLG_PSW_OV_RD, 0);
break;
case FLAG_LE:
case FLAG_GT:
vmimtBinopRRR(8, vmi_XOR, tf, V850_FLG_PSW_SI_WR, V850_FLG_PSW_OV_RD, 0);
vmimtBinopRR (8, vmi_OR, tf, V850_FLG_PSW_ZR_WR, 0);
break;
default:
VMI_ABORT("%s: unimplemented condition", FUNC_NAME); // LCOV_EXCL_LINE
/* no break */
}
// return the condition description
return entry;
}
static void binopRRRCCCC(vmiBinop op, Uns8 cccc, vmiReg gpr_reg3, vmiReg gpr_reg2, vmiReg gpr_reg1) {
v850CondAction action = emitPrepareCondition(cccc);
if(action.op==ACO_ALWAYS) {
vmimtMoveRC(8, V850_TMP_WR(0), 1);
action.flag = V850_TMP_RD(0);
} else if(action.op==ACO_FALSE) {
vmimtBinopRRC(8, vmi_XOR, V850_TMP_WR(0), action.flag, 1, 0);
action.flag = V850_TMP_RD(0);
}
vmiFlags tmpFlags = {
cin:action.flag,
.f = {
V850_FLG_PSW_CO_CONST,
VMI_NOFLAG_CONST,
V850_FLG_PSW_ZR_CONST,
V850_FLG_PSW_SI_CONST,
V850_FLG_PSW_OV_CONST
}
};
vmimtBinopRRR(V850_GPR_BITS, op, gpr_reg3, gpr_reg2, gpr_reg1, &tmpFlags);
}
#define BINOPRRR(_OP,_FLAGS) \
vmimtBinopRRR(V850_GPR_BITS, _OP, gpr_reg3, gpr_reg2, gpr_reg1, _FLAGS)
#define BINOPRR(_OP,_FLAGS) \
vmimtBinopRR(V850_GPR_BITS, _OP, gpr_reg2, gpr_reg1, _FLAGS)
#define BINOPRRC(_OP,_CONST,_FLAGS) \
vmimtBinopRRC(V850_GPR_BITS, _OP, gpr_reg2, gpr_reg1, _CONST, _FLAGS)
#define BINOPRC(_OP,_CONST,_FLAGS) \
vmimtBinopRRC(V850_GPR_BITS, _OP, gpr_reg2, gpr_reg2, _CONST, _FLAGS)
#define UNOPRR(_OP,_FLAGS) \
vmimtUnopRR(V850_GPR_BITS, _OP, gpr_reg2, gpr_reg1, _FLAGS);
static void emitSaturateCheck(vmiReg result) {
// generate sign and zero flags from the (possibly saturated) result
vmimtUnopRR(V850_GPR_BITS, vmi_MOV, VMI_NOREG, result, &flags_ZrSi);
// set sticky saturation flag if there was an overflow
vmimtBinopRR(8, vmi_OR, V850_FLG_PSW_SAT_WR, V850_FLG_PSW_OV_RD, 0);
}
static memEndian getEndian(void) {
return MEM_ENDIAN_LITTLE;
}
static void load (
vmiReg reg2,
vmiReg reg1,
Int32 imm,
Uns8 size,
Bool sign,
v850Architecture arch) {
memEndian endian = getEndian();
//
// Need to check state of alignment
// V850 misaligned access masked
// V850E1/ES misaligned access OK
// V850E2/E2R programmable from IFMAEN
//
Bool snap = False;
if (arch == V850) {
snap = True;
} else if (arch == V850E1) {
snap = False; // Actually dependant upon pin IFMAEN
} else if (arch == V850ES) {
snap = False; // Actually dependant upon pin IFMAEN
} else if (arch == V850E2) {
snap = False; // Actually dependant upon pin IFMAEN
} else if (arch == V850E2R) {
snap = False; // Actually dependant upon pin IFMAEN
} else if (arch == RH850G3M) {
snap = False; // Actually dependant upon pin IFMAEN
}
Uns8 destBits = (size <= 32) ? V850_GPR_BITS : (2*V850_GPR_BITS);
vmimtLoadRRO(destBits, size, imm, reg2, reg1, endian, sign, snap);
}
static void store (
vmiReg reg2,
vmiReg reg1,
Int32 imm,
Uns8 size,
Bool sign,
v850Architecture arch) {
memEndian endian = getEndian();
//
// Need to check state of alignment
// V850 misaligned access masked
// V850E1/ES misaligned access OK
// V850E2/E2R programmable from IFMAEN
//
Bool snap = False;
if (arch == V850) {
snap = True;
} else if (arch == V850E1) {
snap = False; // Actually dependant upon pin IFMAEN
} else if (arch == V850ES) {
snap = False; // Actually dependant upon pin IFMAEN
} else if (arch == V850E2) {
snap = False; // Actually dependant upon pin IFMAEN
} else if (arch == V850E2R) {
snap = False; // Actually dependant upon pin IFMAEN
} else if (arch == RH850G3M) {
snap = False; // Actually dependant upon pin IFMAEN
}
vmimtStoreRRO(size, imm, reg1, reg2, endian, snap);
}
static void divFmt11 (
vmiReg reg1,
vmiReg reg2,
vmiReg reg3,
vmiBinop op,
Uns8 size,
vmiFlagsCP flags
) {
Bool sign = (op == vmi_IDIV) ? True : False;
//
// Clear the overflow flag, this can be set if necessary
// by the exception handler on a divide by zero
//
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
if (size == 32) {
// Extend reg2 to a 64 bit
vmimtMoveExtendRR(V850_GPR_BITS*2, V850_TMP_WR(0), V850_GPR_BITS, reg2, sign);
vmimtDivopRRR(V850_GPR_BITS, op, reg2, reg3, V850_TMP_RD(1), V850_TMP_RD(0), reg1, flags);
} else if (size == 16) {
// Extend reg1(15:0] to a 32 bit
vmimtMoveExtendRR(V850_GPR_BITS, V850_TMP_WR(0), V850_GPR_BITS/2, reg1, sign);
vmimtDivopRRR(V850_GPR_BITS, op, reg2, reg3, VMI_NOREG, reg2, V850_TMP_RD(0), flags);
} else {
VMI_ABORT("%s: unimplemented size %d", FUNC_NAME, size); // LCOV_EXCL_LINE
}
}
static void vmic_Value_to_PSW(v850P v850, Uns32 value) {
IMMTSREG(PSW, value);
v850UnPackPSW(v850);
//
// Check for pending interrupts
//
v850TestInterrupt(v850);
}
static void bitOP (Uns8 bit, vmiReg gpr_reg1, Int32 sdisp, vmiBinop op) {
memEndian endian = getEndian();
// First perform a byte read
vmimtLoadRRO(8, 8, sdisp, V850_TMP_WR(0), gpr_reg1, endian, False, False);
// Test the bit for Zero to set the Z flag
Uns8 setBit = 0x1 << bit;
vmimtBinopRRC(8, vmi_AND, VMI_NOREG, V850_TMP_RD(0), setBit, &flags_Zr);
// UNSet the bit in the TEMPREG
vmimtBinopRC(8, op, V850_TMP_WR(0), setBit, 0);
// Write back the TEMPREG to byte
vmimtStoreRRO(8, sdisp, gpr_reg1, V850_TMP_RD(0), endian, False);
}
//
// Write Default Morpher stub Functions
//
V850_MORPH_FN(morphADD_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_ADD, &flags_CoZrSiOv);
}
V850_MORPH_FN(morphAND_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_AND, &flags_ZrSiOv);
}
V850_MORPH_FN(morphCMP_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_CMP, &flags_CoZrSiOv);
}
V850_MORPH_FN(morphDIVH_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
vmimtMoveExtendRR(V850_GPR_BITS, V850_TMP_WR(0), V850_GPR_BITS/2, gpr_reg1, True);
vmimtBinopRR(V850_GPR_BITS, vmi_IDIV, gpr_reg2, V850_TMP_RD(0), &flags_ZrSi);
}
V850_MORPH_FN(morphMOV_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
vmimtMoveRR(V850_GPR_BITS, gpr_reg2, gpr_reg1);
}
V850_MORPH_FN(morphMULH_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
vmiReg gpr_reg2H = VMI_REG_DELTA(gpr_reg2, 2);
vmimtMulopRRR(V850_GPR_BITS/2, vmi_IMUL, gpr_reg2H, gpr_reg2, gpr_reg2, gpr_reg1, 0);
}
V850_MORPH_FN(morphNOT_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
UNOPRR(vmi_NOT, &flags_ZrSi);
// Special clear Overflow
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphOR_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_OR, &flags_ZrSiOv);
}
V850_MORPH_FN(morphSATADD_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_ADDSQ, &flags_CoZrSiOv);
emitSaturateCheck(gpr_reg2);
}
V850_MORPH_FN(morphSATSUB_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_SUBSQ, &flags_CoZrSiOv);
emitSaturateCheck(gpr_reg2);
}
V850_MORPH_FN(morphSATSUBR_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_RSUBSQ, &flags_CoZrSiOv);
emitSaturateCheck(gpr_reg2);
}
V850_MORPH_FN(morphSUB_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_SUB, &flags_CoZrSiOv);
}
V850_MORPH_FN(morphSUBR_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_RSUB, &flags_CoZrSiOv);
}
V850_MORPH_FN(morphTST_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
vmimtBinopRRR(V850_GPR_BITS, vmi_AND, VMI_NOREG, gpr_reg2, gpr_reg1, &flags_ZrSiOv);
}
V850_MORPH_FN(morphXOR_F01) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_XOR, &flags_ZrSiOv);
}
V850_MORPH_FN(morphDBTRAP_F01A) {
//
// Supported Architecture=V850_ISA_E1
//
morphUnimplemented("DBTRAP_F01A");
}
V850_MORPH_FN(morphNOP_F01A) {
//
// Supported Architecture=V850_ISA_E0
//
}
static void common_RIE(v850MorphStateP state) {
vmimtArgProcessor();
vmimtCall((vmiCallFn)v850ProcessRIE);
}
V850_MORPH_FN(morphRIE_F01A) {
//
// Supported Architecture=ISA_E2
//
common_RIE(state);
}
V850_MORPH_FN(morphRIE_F06X) {
//
// Supported Architecture=ISA_E2
//
common_RIE(state);
}
#define V850_ADDRESS_MASK 0x00fffffe
#define V850E_ADDRESS_MASK 0xfffffffe
V850_MORPH_FN(morphSWITCH_F01D) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
memEndian endian = getEndian();
Int32 pc = state->info.thisPC;
//
// adr <- (PC+2) + (gpr_reg1 << 1)
// PC <- (PC+2) + ((signed(mem(adr,HW)) << 1)
//
// tmpl = gpr_reg1 << 1
vmimtBinopRRC(V850_GPR_BITS, vmi_SHL, V850_TMP_WR(0), gpr_reg1, 1, 0);
// tmph = mem((tmp1 + (thisPC + 2)),HW)
vmimtLoadRRO(V850_GPR_BITS, V850_GPR_BITS/2, (pc + 2), V850_TMP_WR(1), V850_TMP_RD(0), endian, True, True);
// tmph = tmph << 1
vmimtBinopRRC(V850_GPR_BITS, vmi_SHL, V850_TMP_WR(1), V850_TMP_RD(1), 1, 0);
// tmph = tmph + (pc + 2)
vmimtBinopRC(V850_GPR_BITS, vmi_ADD, V850_TMP_WR(1), (pc + 2), 0);
//
// the Next PC is now held in V850_TEMPH_REG
//
vmimtSetAddressMask(V850_ADDRESS_MASK);
vmimtUncondJumpReg(0, V850_TMP_RD(1), VMI_NOREG, vmi_JH_NONE);
}
V850_MORPH_FN(morphSXB_F01C) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_WR(reg1);
vmimtMoveExtendRR(V850_GPR_BITS, gpr_reg1, 8, gpr_reg1, True);
}
V850_MORPH_FN(morphSXH_F01C) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_WR(reg1);
vmimtMoveExtendRR(V850_GPR_BITS, gpr_reg1, 16, gpr_reg1, True);
}
V850_MORPH_FN(morphZXB_F01C) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_WR(reg1);
vmimtMoveExtendRR(V850_GPR_BITS, gpr_reg1, 8, gpr_reg1, False);
}
V850_MORPH_FN(morphZXH_F01C) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_WR(reg1);
vmimtMoveExtendRR(V850_GPR_BITS, gpr_reg1, 16, gpr_reg1, False);
}
V850_MORPH_FN(morphFETRAP_F01E) {
//
// Supported Architecture=ISA_E2
//
Uns32 uimm = state->info.uimm;
vmimtArgProcessor();
vmimtArgUns32(uimm);
vmimtCall((vmiCallFn)v850ProcessFETRAP);
}
V850_MORPH_FN(morphCALLT_F02B) {
//
// Supported Architecture=V850_ISA_E1
//
Uns32 uimm = state->info.uimm;
Int32 pc = state->info.thisPC;
memEndian endian = getEndian();
// CTPSW <- PSW
vmimtRegReadImpl("PSW");
vmimtArgProcessor();
vmimtCallResult((vmiCallFn)v850PackPSW, V850_GPR_BITS, V850_SPR_CTPSW_WR);
// Calculate Jump Address
// calculate adr (CTBP + uimm), get the value into V850_TEMPL_REG
// Jumpaddress = V850_CTBP_REG + mem(LoHalf, V850_CTBP_REG+uimm)
// The immediate value is left shifted by 1
//
vmimtLoadRRO(V850_GPR_BITS, V850_GPR_BITS/2, uimm<<1, V850_TMP_WR(0), V850_SPR_CTBP_RD, endian, False, True);
vmimtBinopRR(V850_GPR_BITS, vmi_ADD, V850_TMP_WR(0), V850_SPR_CTBP_RD, 0);
//
// Jump and link through callt
// CTPC <- PC + 2 (Return PC)
//
vmimtUncondJumpReg(pc+2, V850_TMP_RD(0), V850_SPR_CTPC_RD, vmi_JH_NONE);
}
V850_MORPH_FN(morphRMTRAP_F01A) {
//
// Supported Architecture=ISA_E2
//
/* LCOV_EXCL_LINE */ morphUnimplemented("RMTRAP_F01A");
}
V850_MORPH_FN(morphSYNCM_F01A) {
//
// Supported Architecture=ISA_E2
//
// NOP
}
V850_MORPH_FN(morphSYNCP_F01A) {
//
// Supported Architecture=ISA_E2
//
// NOP
}
//
// CALL, RETURNE, or NONE
//
static void jmp (v850MorphStateP state, Uns8 reg1, Int32 sdisp) {
vmiReg gpr_reg1 = V850_GPR_WR(reg1);
if (sdisp) {
vmimtBinopRRC(V850_GPR_BITS, vmi_ADD, V850_TMP_WR(0), gpr_reg1, sdisp, 0);
vmimtUncondJumpReg(0, V850_TMP_WR(0), VMI_NOREG, vmi_JH_NONE);
} else {
vmiJumpHint jump_hint;
//
// If the preceding instruction manufactures a link address save, then
// assume this is a call; otherwise, if the register is one that has
// previously been used as a link register, assume it is a return;
// otherwise, assume an indirect jump.
//
if (state->blockState->jmpIsCall) {
jump_hint = vmi_JH_CALL;
state->blockState->jmpIsCall = False;
} else if (state->v850->REG_RETMASK & (1<<reg1)) {
jump_hint = vmi_JH_RETURN;
} else {
jump_hint = vmi_JH_NONE;
}
vmimtUncondJumpReg(0, gpr_reg1, VMI_NOREG, jump_hint);
}
}
V850_MORPH_FN(morphJMP_F01B) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
jmp(state, reg1, 0);
}
V850_MORPH_FN(morphADD_F02S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int16 simm = state->info.simm;
BINOPRC(vmi_ADD, simm, &flags_CoZrSiOv);
}
V850_MORPH_FN(morphCMP_F02S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int16 simm = state->info.simm;
BINOPRC(vmi_CMP, simm, &flags_CoZrSiOv);
}
V850_MORPH_FN(morphMOV_F02S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int16 simm = state->info.simm;
vmimtMoveRC(V850_GPR_BITS, gpr_reg2, simm);
}
V850_MORPH_FN(morphMULH_F02S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int16 simm = state->info.simm;
vmiReg gpr_reg2H = VMI_REG_DELTA(gpr_reg2, 2);
vmimtMoveRC(V850_GPR_BITS/2, V850_TMP_WR(0), simm);
vmimtMulopRRR(V850_GPR_BITS/2, vmi_IMUL, gpr_reg2H, gpr_reg2, gpr_reg2, V850_TMP_RD(0), 0);
}
V850_MORPH_FN(morphSATADD_F02S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int16 simm = state->info.simm;
BINOPRC(vmi_ADDSQ, simm, &flags_CoZrSiOv);
emitSaturateCheck(gpr_reg2);
}
V850_MORPH_FN(morphSAR_F02U) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns16 uimm = state->info.uimm;
BINOPRC(vmi_SAR, uimm, &flags_CoZrSi);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphSHL_F02U) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns16 uimm = state->info.uimm;
BINOPRC(vmi_SHL, uimm, &flags_CoZrSi);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphSHR_F02U) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns16 uimm = state->info.uimm;
BINOPRC(vmi_SHR, uimm, &flags_CoZrSi);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
static void bcond(v850MorphStateP state) {
Uns8 cond = state->info.cond;
v850Addr targetPC = state->info.targetPC;
v850CondAction action = emitPrepareCondition(cond);
if(action.op==ACO_ALWAYS) {
vmimtUncondJump(0, targetPC, VMI_NOREG, vmi_JH_NONE);
} else {
vmimtCondJump(action.flag, action.op==ACO_TRUE, 0, targetPC, VMI_NOREG, vmi_JH_NONE);
}
}
V850_MORPH_FN(morphBCOND_F03) {
//
// Supported Architecture=V850_ISA_E0
//
bcond(state);
}
V850_MORPH_FN(morphSLD_BU_F04DB) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 udisp = state->info.udisp;
vmiReg gpr_ep = V850_GPR_RD(30);
load(gpr_reg2, gpr_ep, udisp, 8, False, state->info.arch);
}
V850_MORPH_FN(morphSLD_HU_F04DH) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 udisp = state->info.udisp;
vmiReg gpr_ep = V850_GPR_RD(30);
load(gpr_reg2, gpr_ep, udisp, 16, False, state->info.arch);
}
V850_MORPH_FN(morphSLD_B_F04LA) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 udisp = state->info.udisp;
vmiReg gpr_ep = V850_GPR_RD(30);
load(gpr_reg2, gpr_ep, udisp, 8, True, state->info.arch);
}
V850_MORPH_FN(morphSLD_H_F04LB) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 udisp = state->info.udisp;
vmiReg gpr_ep = V850_GPR_WR(30);
load(gpr_reg2, gpr_ep, udisp, 16, True, state->info.arch);
}
V850_MORPH_FN(morphSLD_W_F04LC) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 udisp = state->info.udisp;
vmiReg gpr_ep = V850_GPR_WR(30);
load(gpr_reg2, gpr_ep, udisp, 32, True, state->info.arch);
}
V850_MORPH_FN(morphSST_B_F04SA) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 udisp = state->info.udisp;
vmiReg gpr_ep = V850_GPR_WR(30);
store(gpr_reg2, gpr_ep, udisp, 8, True, state->info.arch);
}
V850_MORPH_FN(morphSST_H_F04SB) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 udisp = state->info.udisp;
vmiReg gpr_ep = V850_GPR_WR(30);
store(gpr_reg2, gpr_ep, udisp, 16, True, state->info.arch);
}
V850_MORPH_FN(morphSST_W_F04SC) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 udisp = state->info.udisp;
vmiReg gpr_ep = V850_GPR_WR(30);
store(gpr_reg2, gpr_ep, udisp, 32, True, state->info.arch);
}
//
// CALL or NONE
//
static void jarl1 (v850MorphStateP state, Uns8 lr, Int32 sdisp) {
v850Addr pc = state->info.thisPC;
v850Addr isize = state->info.instrsize;
vmiReg gpr_lr = V850_GPR_WR(lr);
v850Addr targetPC = state->info.targetPC;
vmiJumpHint jump_hint;
if (sdisp == isize) {
//
// This indicates a manufactured jump and link in a strange idiom
//
jump_hint = vmi_JH_NONE;
state->blockState->jmpIsCall = True;
} else {
//
// indicate that this register may contain a link address
//
jump_hint = vmi_JH_CALL;
state->v850->REG_RETMASK |= (1<<lr);
}
vmimtUncondJump(pc+isize, targetPC, gpr_lr, jump_hint);
}
V850_MORPH_FN(morphJARL_F05A) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg2 = state->info.reg2;
Int32 sdisp = state->info.sdisp;
jarl1(state, reg2, sdisp);
}
static void jr (v850MorphStateP state, Int32 sdisp) {
v850Addr targetPC = state->info.targetPC;
vmimtUncondJump(0, targetPC, VMI_NOREG, vmi_JH_NONE);
}
V850_MORPH_FN(morphJR_F05B) {
//
// Supported Architecture=V850_ISA_E0
//
Int32 sdisp = state->info.sdisp;
jr(state, sdisp);
}
V850_MORPH_FN(morphADDI_F06S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int16 simm = state->info.simm;
BINOPRRC(vmi_ADD, simm, &flags_CoZrSiOv);
}
V850_MORPH_FN(morphMOVEA_F06S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int16 simm = state->info.simm;
BINOPRRC(vmi_ADD, simm, 0);
}
V850_MORPH_FN(morphMULHI_F06S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int16 simm = state->info.simm;
vmiReg gpr_reg2H = VMI_REG_DELTA(gpr_reg2, 2);
vmimtMoveRC(V850_GPR_BITS/2, V850_TMP_WR(0), simm);
vmimtMulopRRR(V850_GPR_BITS/2, vmi_IMUL, gpr_reg2H, gpr_reg2, gpr_reg1, V850_TMP_RD(0), 0);
}
V850_MORPH_FN(morphSATSUBI_F06S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int16 simm = state->info.simm;
BINOPRRC(vmi_SUBSQ, simm, &flags_CoZrSiOv);
emitSaturateCheck(gpr_reg2);
}
V850_MORPH_FN(morphJARL_F06SA) {
//
// Supported Architecture=ISA_E2
//
Uns8 reg1 = state->info.reg1;
Int32 sdisp = state->info.sdisp;
jarl1(state, reg1, sdisp);
}
V850_MORPH_FN(morphJMP_F06SB) {
//
// Supported Architecture=ISA_E2
//
Uns8 reg1 = state->info.reg1;
Int32 sdisp = state->info.sdisp;
jmp(state, reg1, sdisp);
}
V850_MORPH_FN(morphJR_F06SC) {
//
// Supported Architecture=ISA_E2
//
Int32 sdisp = state->info.sdisp;
jr(state, sdisp);
}
V850_MORPH_FN(morphANDI_F06U) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns16 uimm = state->info.uimm;
BINOPRRC(vmi_AND, uimm, &flags_ZrSiOv);
}
V850_MORPH_FN(morphMOVHI_F06S) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns16 simm = state->info.simm;
BINOPRRC(vmi_ADD, SHIFTL(simm,16), 0);
}
V850_MORPH_FN(morphORI_F06U) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns16 uimm = state->info.uimm;
BINOPRRC(vmi_OR, uimm, &flags_ZrSiOv);
}
V850_MORPH_FN(morphXORI_F06U) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns16 uimm = state->info.uimm;
BINOPRRC(vmi_XOR, uimm, &flags_ZrSiOv);
}
V850_MORPH_FN(morphMOV_F06UA) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_WR(reg1);
Uns32 uimm = state->info.uimm;
if (VMI_REG_EQUAL(gpr_reg1, VMI_NOREG)) {
VMI_ABORT("%s: Attempt mov imm32, r0", FUNC_NAME); // LCOV_EXCL_LINE
} else {
vmimtMoveRC(V850_GPR_BITS, gpr_reg1, uimm);
}
}
V850_MORPH_FN(morphLD_BU_F07C) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int32 sdisp = state->info.sdisp;
load(gpr_reg2, gpr_reg1, sdisp, 8, False, state->info.arch);
}
V850_MORPH_FN(morphLD_B_F07LA) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int32 sdisp = state->info.sdisp;
load(gpr_reg2, gpr_reg1, sdisp, 8, True, state->info.arch);
}
V850_MORPH_FN(morphLD_H_F07LB) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int32 sdisp = state->info.sdisp;
load(gpr_reg2, gpr_reg1, sdisp, 16, True, state->info.arch);
}
V850_MORPH_FN(morphLD_HU_F07LB) {
//
// Supported Architecture=V850_ISA_E1
//
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int32 sdisp = state->info.sdisp;
load(gpr_reg2, gpr_reg1, sdisp, 16, False, state->info.arch);
}
V850_MORPH_FN(morphLD_W_F07LB) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int32 sdisp = state->info.sdisp;
load(gpr_reg2, gpr_reg1, sdisp, 32, True, state->info.arch);
}
V850_MORPH_FN(morphST_B_F07SA) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int32 sdisp = state->info.sdisp;
store(gpr_reg2, gpr_reg1, sdisp, 8, True, state->info.arch);
}
V850_MORPH_FN(morphST_H_F07SB) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int32 sdisp = state->info.sdisp;
store(gpr_reg2, gpr_reg1, sdisp, 16, True, state->info.arch);
}
V850_MORPH_FN(morphST_W_F07SB) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Int32 sdisp = state->info.sdisp;
store(gpr_reg2, gpr_reg1, sdisp, 32, True, state->info.arch);
}
V850_MORPH_FN(morphCLR1_F08) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 bit = state->info.bit;
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Int32 sdisp = state->info.sdisp;
bitOP(bit, gpr_reg1, sdisp, vmi_ANDN);
}
V850_MORPH_FN(morphNOT1_F08) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 bit = state->info.bit;
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Int32 sdisp = state->info.sdisp;
bitOP(bit, gpr_reg1, sdisp, vmi_XOR);
}
V850_MORPH_FN(morphSET1_F08) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 bit = state->info.bit;
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Int32 sdisp = state->info.sdisp;
bitOP(bit, gpr_reg1, sdisp, vmi_OR);
}
V850_MORPH_FN(morphTST1_F08) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 bit = state->info.bit;
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Int32 sdisp = state->info.sdisp;
memEndian endian = getEndian();
// First perform a byte read
vmimtLoadRRO(8, 8, sdisp, V850_TMP_WR(0), gpr_reg1, endian, False, False);
// Test the bit for Zero to set the Z flag
Uns8 setBit = 0x1 << bit;
vmimtBinopRRC(8, vmi_AND, VMI_NOREG, V850_TMP_RD(0), setBit, &flags_Zr);
}
V850_MORPH_FN(morphSASF_F09) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 cccc = state->info.cccc;
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
// vmiReg reg2 = getuRd1(&state->info);
// Int32 cond = state->info.cond;
v850CondAction action = emitPrepareCondition(cccc);
// Firstly always shift left reg2
vmimtBinopRC(V850_GPR_BITS, vmi_SHL, gpr_reg2, 1, 0);
// if test is true then perform logical OR with 0x1
// V850_TEMPL_REG
if(action.op==ACO_ALWAYS) {
vmimtBinopRC(V850_GPR_BITS, vmi_OR, gpr_reg2, 0x1, 0);
} else {
vmimtBinopRRC(V850_GPR_BITS, vmi_OR, V850_TMP_WR(0), gpr_reg2, 0x1, 0);
vmimtCondMoveRRR(V850_GPR_BITS, action.flag, action.op==ACO_TRUE, gpr_reg2, V850_TMP_RD(0), gpr_reg2);
}
}
V850_MORPH_FN(morphSETF_F09) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 cccc = state->info.cccc;
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
v850CondAction action = emitPrepareCondition(cccc);
if(action.op==ACO_ALWAYS) {
vmimtMoveRC(V850_GPR_BITS, gpr_reg2, 1);
} else {
vmimtCondMoveRCC(V850_GPR_BITS, action.flag, action.op==ACO_TRUE, gpr_reg2, 1, 0);
}
}
V850_MORPH_FN(morphSAR_F09RR) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_SAR, &flags_CoZrSi);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphSHL_F09RR) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_SHL, &flags_CoZrSi);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphSHR_F09RR) {
//
// Supported Architecture=V850_ISA_E0
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
BINOPRR(vmi_SHR, &flags_CoZrSi);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphCLR1_F09RS2) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
Uns8 reg2 = state->info.reg2;
vmiReg rs1 = V850_GPR_RD(reg2);
vmiReg rs2 = V850_GPR_WR(reg1);
memEndian endian = getEndian();
// Generate the shift value in a register V850_TEMPH_REG
vmimtMoveRC(V850_GPR_BITS, V850_TMP_WR(1), 0x1);
vmimtBinopRRC(V850_GPR_BITS, vmi_AND, V850_TMP_WR(0), rs1, 0x7, 0);
vmimtBinopRR(V850_GPR_BITS, vmi_SHL, V850_TMP_WR(1), V850_TMP_RD(0), 0);
// First perform a byte read
vmimtLoadRRO(8, 8, 0, V850_TMP_WR(0), rs2, endian, False, False);
// Test the bit for Zero to set the Z flag
vmimtBinopRRR(8, vmi_AND, VMI_NOREG, V850_TMP_RD(0), V850_TMP_RD(1), &flags_Zr);
// UNSet the bit in the TEMPREG
vmimtBinopRR(8, vmi_ANDN, V850_TMP_WR(0), V850_TMP_RD(1), 0);
// Write back the TEMPREG to byte
vmimtStoreRRO(8, 0, rs2, V850_TMP_RD(0), endian, False);
}
V850_MORPH_FN(morphNOT1_F09RS2) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
Uns8 reg2 = state->info.reg2;
vmiReg rs1 = V850_GPR_RD(reg2);
vmiReg rs2 = V850_GPR_WR(reg1);
memEndian endian = getEndian();
// Generate the shift value in a register V850_TEMPH_REG
vmimtMoveRC(V850_GPR_BITS, V850_TMP_WR(1), 0x1);
vmimtBinopRRC(V850_GPR_BITS, vmi_AND, V850_TMP_WR(0), rs1, 0x7, 0);
vmimtBinopRR(V850_GPR_BITS, vmi_SHL, V850_TMP_WR(1), V850_TMP_RD(0), 0);
// First perform a byte read
vmimtLoadRRO(8, 8, 0, V850_TMP_WR(0), rs2, endian, False, False);
// Test the bit for Zero to set the Z flag
vmimtBinopRRR(8, vmi_AND, VMI_NOREG, V850_TMP_RD(0), V850_TMP_RD(1), &flags_Zr);
// UNSet the bit in the TEMPREG
vmimtBinopRR(8, vmi_XOR, V850_TMP_WR(0), V850_TMP_RD(1), 0);
// Write back the TEMPREG to byte
vmimtStoreRRO(8, 0, rs2, V850_TMP_RD(0), endian, False);
}
V850_MORPH_FN(morphSET1_F09RS2) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
Uns8 reg2 = state->info.reg2;
vmiReg rs1 = V850_GPR_RD(reg2);
vmiReg rs2 = V850_GPR_WR(reg1);
memEndian endian = getEndian();
// Generate the shift value in a register V850_TEMPH_REG
vmimtMoveRC(V850_GPR_BITS, V850_TMP_WR(1), 0x1);
vmimtBinopRRC(V850_GPR_BITS, vmi_AND, V850_TMP_WR(0), rs1, 0x7, 0);
vmimtBinopRR(V850_GPR_BITS, vmi_SHL, V850_TMP_WR(1), V850_TMP_RD(0), 0);
// First perform a byte read
vmimtLoadRRO(8, 8, 0, V850_TMP_WR(0), rs2, endian, False, False);
// Test the bit for Zero to set the Z flag
vmimtBinopRRR(8, vmi_AND, VMI_NOREG, V850_TMP_RD(0), V850_TMP_RD(1), &flags_Zr);
// Set the bit in the TEMPREG
vmimtBinopRR(8, vmi_OR, V850_TMP_WR(0), V850_TMP_RD(1), 0);
// Write back the TEMPREG to byte
vmimtStoreRRO(8, 0, rs2, V850_TMP_RD(0), endian, False);
}
V850_MORPH_FN(morphTST1_F09RS2) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
Uns8 reg2 = state->info.reg2;
vmiReg rs1 = V850_GPR_RD(reg2);
vmiReg rs2 = V850_GPR_WR(reg1);
memEndian endian = getEndian();
// Generate the shift value in a register V850_TEMPH_REG
vmimtMoveRC(V850_GPR_BITS, V850_TMP_WR(1), 0x1);
vmimtBinopRRC(V850_GPR_BITS, vmi_AND, V850_TMP_WR(0), rs1, 0x7, 0);
vmimtBinopRR(V850_GPR_BITS, vmi_SHL, V850_TMP_WR(1), V850_TMP_RD(0), 0);
// First perform a byte read
vmimtLoadRRO(8, 8, 0, V850_TMP_WR(0), rs2, endian, False, False);
// Test the bit for Zero to set the Z flag
vmimtBinopRRR(8, vmi_AND, VMI_NOREG, V850_TMP_WR(0), V850_TMP_RD(1), &flags_Zr);
}
static void searchInRegister(vmiReg tgt, vmiReg src, vmiUnop op, Uns32 CYMask) {
vmiLabelP setflags = vmimtNewLabel();
//
// bitpos 31=1, bitpos 0=32
//
//
// Init (temp) result to 0, and ZR=1
//
vmimtMoveRC(V850_GPR_BITS, V850_TMP_WR(0), 0);
//
// Special cases
// SCH0 && reg2==0xFFFFFFFF
// SCH1 && reg2==0x00000000
//
Uns32 special = (op==vmi_CLO || op==vmi_CTO) ? 0xFFFFFFFF : 0x00000000;
vmimtCompareRCJumpLabel(V850_GPR_BITS, vmi_COND_EQ, src, special, setflags);
//
// else calculate and adjust +1
//
vmimtUnopRR(V850_GPR_BITS, op, V850_TMP_WR(0), src, 0);
vmimtBinopRC(V850_GPR_BITS, vmi_ADD, V850_TMP_WR(0), 1, 0);
//
// Set remaining flags
//
vmimtInsertLabel(setflags);
// Z = (gpr_reg3==0) ? 1 : 0
vmimtBinopRC(V850_GPR_BITS, vmi_OR, V850_TMP_WR(0), 0, &flags_Zr);
// CY = (src == CYMask)
vmimtCompareRC(V850_GPR_BITS, vmi_COND_EQ, src, CYMask, V850_FLG_PSW_CO_WR);
// OV == S == 0
vmimtMoveRC(V850_GPR_BITS/4, V850_FLG_PSW_OV_WR, 0);
vmimtMoveRC(V850_GPR_BITS/4, V850_FLG_PSW_SI_WR, 0);
// copy to target register
vmimtMoveRR(V850_GPR_BITS, tgt, V850_TMP_RD(0));
}
V850_MORPH_FN(morphSCH0L_F09RR2) {
//
// Supported Architecture=ISA_E2
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
searchInRegister(gpr_reg3, gpr_reg2, vmi_CLO, 0xFFFFFFFE);
}
V850_MORPH_FN(morphSCH0R_F09RR2) {
//
// Supported Architecture=ISA_E2
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
searchInRegister(gpr_reg3, gpr_reg2, vmi_CTO, 0x7FFFFFFF);
}
V850_MORPH_FN(morphSCH1L_F09RR2) {
//
// Supported Architecture=ISA_E2
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
searchInRegister(gpr_reg3, gpr_reg2, vmi_CLZ, 0x00000001);
}
V850_MORPH_FN(morphSCH1R_F09RR2) {
//
// Supported Architecture=ISA_E2
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
searchInRegister(gpr_reg3, gpr_reg2, vmi_CTZ, 0x80000000);
}
V850_MORPH_FN(morphCTRET_F10A) {
//
// Supported Architecture=V850_ISA_E1
//
// PSW <- CTPSW
vmimtRegWriteImpl("PSW");
vmimtArgProcessor();
vmimtArgReg(V850_GPR_BITS, V850_SPR_CTPSW_RD);
vmimtCall((vmiCallFn)vmic_Value_to_PSW);
//
// return to CTPC
//
vmimtUncondJumpReg(0, V850_SPR_CTPC_RD, VMI_NOREG, vmi_JH_NONE);
}
V850_MORPH_FN(morphDBRET_F10A) {
//
// Supported Architecture=V850_ISA_E1
//
// Uns8 b16 = state->info.b16;
morphUnimplemented("DBRET_F10A");
}
V850_MORPH_FN(morphDI_F10A) {
//
// Supported Architecture=V850_ISA_E0
//
// RH850G3M UM page 216.
// If the MCTL.UIC bit has been cleared to 0, this instruction is a supervisor-level instruction.
// If the MCTL.UIC bit has been set to 1, this instruction can always be executed.
// @@@shinbo: UM_PrivException or checking state->v850->mode might be called in execution time, not in morph time ?
vmiLabelP UIC_1 = vmimtNewLabel();
vmiLabelP END = vmimtNewLabel();
Bool UserMode = (state->v850->mode==RH850_M_USER) || (state->v850->mode==RH850_M_USER_MPU);
if (UserMode) {
vmimtBinopRRC (V850_GPR_BITS, vmi_AND , V850_TMP_WR(0), V850_SPR_MCTL_RD, 0x00000001, 0);
vmimtCompareRCJumpLabel(V850_GPR_BITS, vmi_COND_EQ, V850_TMP_RD(0), 0x00000001, UIC_1);
// UIC=0
// Supervisor instruction Exception
vmimtArgProcessor();
vmimtCall((vmiCallFn) v850ProcessPIE);
vmimtUncondJumpLabel(END);
}
vmimtInsertLabel(UIC_1);
vmimtMoveRC(8, V850_FLG_PSW_ID_WR, 1);
vmimtInsertLabel(END);
}
static void vmic_evaluate_pending_interrupts (v850P v850) {
v850TestInterrupt(v850);
}
V850_MORPH_FN(morphEI_F10A) {
//
// Supported Architecture=V850_ISA_E0
//
vmiLabelP UIC_1 = vmimtNewLabel();
vmiLabelP END = vmimtNewLabel();
Bool UserMode = (state->v850->mode==RH850_M_USER) || (state->v850->mode==RH850_M_USER_MPU);
if (UserMode) {
vmimtBinopRRC (V850_GPR_BITS, vmi_AND , V850_TMP_WR(0), V850_SPR_MCTL_RD, 0x00000001, 0);
vmimtCompareRCJumpLabel(V850_GPR_BITS, vmi_COND_EQ, V850_TMP_RD(0), 0x00000001, UIC_1);
// UIC=0
// Supervisor instruction Exception
vmimtArgProcessor();
vmimtCall((vmiCallFn) v850ProcessPIE);
vmimtUncondJumpLabel(END);
}
vmimtInsertLabel(UIC_1);
vmimtMoveRC(8, V850_FLG_PSW_ID_WR, 0);
//
// We need to check if any Interrupts are pending, and if so
// make a call to evaluate the pending interrupt
//
vmimtArgProcessor();
vmimtCall((vmiCallFn)vmic_evaluate_pending_interrupts);
vmimtInsertLabel(END);
}
static void vmic_WriteNetPort_mireti(v850P v850) {
vmirtWriteNetPort((vmiProcessorP)v850, v850->netValue.mireti, 1);
}
static void vmic_updateISPR(v850P v850) {
// RH850G3M UM 4.2.1 (1) EP bit of PSW register
// Depending on the EP bit setting, the operation changes when the EIRET or FERET instruction is executed. If the
// EP bit is cleared to 0, the bit with the highest priority (0 is the highest) among the bits set to 1 in ISPR.ISP15 to
// ISPR.ISP0 is cleared to 0. Also, the end of the exception handling routine is reported to the external interrupt
// controller.
// RH850G3M UM 3.3.1 (5) INTCFG - Interrupt function setting
// INTCFG.ISPC :
// If this bit is set to 1, the bits of the ISPR register are not updated by the
// acknowledgment of an interrupt (EIINTn) or by execution of the EIRET
// instruction. In this case, the bits can be updated by an LDSR instruction
// executed by the program.
if (v850->configInfo.arch == RH850G3M) {
if (v850->FLG_PSW_EP == 0) { // 17/03/06 esol trinity shinbo
if (v850->SPR_INTCFG.ISPC == 0) {
// When doing EIRET instruction, clear to 0 smallest bit set to 1.
v850->SPR_ISPR.reg &= (v850->SPR_ISPR.reg - 1);
}
}
}
}
static void updateISPR() {
vmimtArgProcessor();
vmimtCall((vmiCallFn) vmic_updateISPR);
}
static void restorePSW (vmiReg psw) {
vmimtRegWriteImpl("PSW");
vmimtArgProcessor();
vmimtArgReg(V850_GPR_BITS, psw);
vmimtCall((vmiCallFn)vmic_Value_to_PSW);
}
static void notifyRETI () {
vmiLabelP ep = vmimtNewLabel();
vmimtCondJumpLabel(V850_FLG_PSW_EP_RD, True, ep);
vmimtArgProcessor();
vmimtCall((vmiCallFn)vmic_WriteNetPort_mireti);
vmimtInsertLabel(ep);
}
V850_MORPH_FN(morphEIRET_F10A) {
//
// Supported Architecture=ISA_E2
//
if (UM_PrivException(state)) {
} else {
//
updateISPR();
// PSW = V850_EIPSW_REG
restorePSW(V850_SPR_EIPSW_RD);
// need to send event on mireti signal
notifyRETI();
// PC = V850_EIPC_REG
vmimtUncondJumpReg(0, V850_SPR_EIPC_RD, VMI_NOREG, vmi_JH_NONE);
}
}
V850_MORPH_FN(morphFERET_F10A) {
//
// Supported Architecture=ISA_E2
//
if (UM_PrivException(state)) {
} else {
// PSW = V850_EIPSW_REG
restorePSW(V850_SPR_FEPSW_RD);
// need to send event on mireti signal
notifyRETI();
// PC = V850_EIPC_REG
vmimtUncondJumpReg(0, V850_SPR_FEPC_RD, VMI_NOREG, vmi_JH_NONE);
}
}
V850_MORPH_FN(morphHALT_F10A) {
//
// Supported Architecture=V850_ISA_E0
//
// Uns8 b16 = state->info.b16;
if (UM_PrivException(state)) {
} else {
vmimtHalt();
}
}
V850_MORPH_FN(morphRETI_F10A) {
//
// Supported Architecture=V850_ISA_E0
//
vmiLabelP noep = vmimtNewLabel();
vmiLabelP nonmi = vmimtNewLabel();
// if PSW.EP { PC = EIPC; PSW = EIPSW } {
// else if PSW.NP { PC = FEPC; PSW = FEPSW } {
// else { PC = EIPC; PSW = EIPSW }
vmimtCondJumpLabel(V850_FLG_PSW_EP_RD, False, noep);
// if PSW.EP == True
// PSW = V850_EIPSW_REG
restorePSW(V850_SPR_EIPSW_RD);
// PC = V850_EIPC_REG
vmimtUncondJumpReg(0, V850_SPR_EIPC_RD, VMI_NOREG, vmi_JH_NONE);
vmimtInsertLabel(noep);
vmimtCondJumpLabel(V850_FLG_PSW_NP_RD, False, nonmi);
// else if PSW.NP == True
// PSW = V850_FEPSW_REG
restorePSW(V850_SPR_FEPSW_RD);
// PC = V850_FEPC_REG
vmimtUncondJumpReg(0, V850_SPR_FEPC_RD, VMI_NOREG, vmi_JH_NONE);
vmimtInsertLabel(nonmi);
// else if PSW.NP == False && PSW.EP == False
// PSW = V850_EIPSW_REG
restorePSW(V850_SPR_EIPSW_RD);
// need to send event on mireti signal
notifyRETI();
// PC = V850_EIPC_REG
vmimtUncondJumpReg(0, V850_SPR_EIPC_RD, VMI_NOREG, vmi_JH_NONE);
}
V850_MORPH_FN(morphTRAP_F10B) {
//
// Supported Architecture=V850_ISA_E0
//
Uns16 uimm = state->info.uimm;
Uns32 RETPC = state->info.thisPC + state->info.instrsize;
Int32 VPC = 0x40 | (uimm & 0x10);
Uns32 CC = VPC | uimm;
// EIPC <- PC
vmimtMoveRC(V850_GPR_BITS, V850_SPR_EIPC_WR, RETPC);
// EIPSW <- PSW
vmimtRegReadImpl("PSW");
vmimtArgProcessor();
vmimtCallResult((vmiCallFn)v850PackPSW, V850_GPR_BITS, V850_SPR_EIPSW_WR);
// ECR.EICC = alias(EIIC(E2R))
vmimtMoveRC(V850_GPR_BITS, V850_SPR_EIIC_WR, CC);
// PSW.EP <- 1
vmimtMoveRC(8, V850_FLG_PSW_EP_WR, 1);
// PSW.ID <- 1
vmimtMoveRC(8, V850_FLG_PSW_ID_WR, 1);
// PC <- Vector PC
vmimtUncondJump(0, VPC, VMI_NOREG, vmi_JH_NONE);
}
V850_MORPH_FN(morphDIV_F11) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
divFmt11(gpr_reg1, gpr_reg2, gpr_reg3, vmi_IDIV, 32, &flags_ZrSi);
}
V850_MORPH_FN(morphDIVH_F11) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
divFmt11(gpr_reg1, gpr_reg2, gpr_reg3, vmi_IDIV, 16, &flags_ZrSi);
}
V850_MORPH_FN(morphDIVHU_F11) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
divFmt11(gpr_reg1, gpr_reg2, gpr_reg3, vmi_DIV, 16, &flags_ZrSi);
}
V850_MORPH_FN(morphDIVQ_F11) {
//
// Supported Architecture=ISA_E2
//
morphDIV_F11(state);
}
V850_MORPH_FN(morphDIVQU_F11) {
//
// Supported Architecture=ISA_E2
//
morphDIVU_F11(state);
}
V850_MORPH_FN(morphDIVU_F11) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
divFmt11(gpr_reg1, gpr_reg2, gpr_reg3, vmi_DIV, 32, &flags_ZrSi);
}
V850_MORPH_FN(morphMUL_F11) {
Uns8 reg1 = state->info.reg1;
Uns8 reg2 = state->info.reg2;
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
vmimtMulopRRR(V850_GPR_BITS, vmi_IMUL, gpr_reg3, gpr_reg2, gpr_reg2, gpr_reg1, 0);
}
V850_MORPH_FN(morphMULU_F11) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg1 = state->info.reg1;
Uns8 reg2 = state->info.reg2;
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
vmimtMulopRRR(V850_GPR_BITS, vmi_MUL, gpr_reg3, gpr_reg2, gpr_reg2, gpr_reg1, 0);
}
V850_MORPH_FN(morphSAR_F11) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
BINOPRRR(vmi_SAR, &flags_CoZrSi);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphSATADD_F11) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
BINOPRRR(vmi_ADDSQ, &flags_CoZrSiOv);
emitSaturateCheck(gpr_reg3);
}
V850_MORPH_FN(morphSATSUB_F11) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
BINOPRRR(vmi_SUBSQ, &flags_CoZrSiOv);
emitSaturateCheck(gpr_reg3);
}
V850_MORPH_FN(morphSHL_F11) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
BINOPRRR(vmi_SHL, &flags_CoZrSi);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphSHR_F11) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
BINOPRRR(vmi_SHR, &flags_CoZrSi);
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphMAC_F11A) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_RD(reg3);
Uns8 reg4 = state->info.reg4;
vmiReg gpr_reg4 = V850_GPR_WR(reg4);
//
// r4(64) = (r2(32) * r1(32)) + r3(64)
//
vmimtMulopRRR(V850_GPR_BITS, vmi_IMUL, V850_TMP_WR(1), V850_TMP_WR(0), gpr_reg2, gpr_reg1, 0);
vmimtBinopRRR(V850_GPR_BITS*2, vmi_ADD, gpr_reg4, V850_TMP_RD(0), gpr_reg3, 0);
}
V850_MORPH_FN(morphMACU_F11A) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_RD(reg3);
Uns8 reg4 = state->info.reg4;
vmiReg gpr_reg4 = V850_GPR_WR(reg4);
//
// r4(64) = (r2(32) * r1(32)) + r3(64)
//
vmimtMulopRRR(V850_GPR_BITS, vmi_MUL, V850_TMP_WR(1), V850_TMP_WR(0), gpr_reg2, gpr_reg1, 0);
vmimtBinopRRR(V850_GPR_BITS*2, vmi_ADD, gpr_reg4, V850_TMP_RD(0), gpr_reg3, 0);
}
V850_MORPH_FN(morphADF_F11B) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 cccc = state->info.cccc;
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
binopRRRCCCC(vmi_ADC, cccc, gpr_reg3, gpr_reg2, gpr_reg1);
}
V850_MORPH_FN(morphCMOV_F11B) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 cccc = state->info.cccc;
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
v850CondAction action = emitPrepareCondition(cccc);
if(action.op==ACO_ALWAYS) {
vmimtMoveRR(V850_GPR_BITS, gpr_reg3, gpr_reg1);
} else {
vmimtCondMoveRRR(V850_GPR_BITS, action.flag, action.op==ACO_TRUE, gpr_reg3, gpr_reg1, gpr_reg2);
}
}
V850_MORPH_FN(morphSBF_F11B) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 cccc = state->info.cccc;
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
binopRRRCCCC(vmi_SBB, cccc, gpr_reg3, gpr_reg2, gpr_reg1);
}
V850_MORPH_FN(morphMUL_F12S) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg2 = state->info.reg2;
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int16 simm = state->info.simm;
//
// TODO - require a vmimtMulopRRC();
//
// Move constant into temporary register
vmimtMoveRC(V850_GPR_BITS, V850_TMP_WR(0), simm);
vmimtMulopRRR(V850_GPR_BITS, vmi_IMUL, gpr_reg3, gpr_reg2, gpr_reg2, V850_TMP_RD(0), 0);
}
V850_MORPH_FN(morphMULU_F12U) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg2 = state->info.reg2;
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Uns16 uimm = state->info.uimm;
//
// TODO - require a vmimtMulopRRC();
//
// Move constant into temporary register
vmimtMoveRC(V850_GPR_BITS, V850_TMP_WR(0), uimm);
vmimtMulopRRR(V850_GPR_BITS, vmi_MUL, gpr_reg3, gpr_reg2, gpr_reg2, V850_TMP_RD(0), 0);
}
V850_MORPH_FN(morphCAXI_F11C) {
//
// Supported Architecture=ISA_E2
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
vmiLabelP nostore = vmimtNewLabel();
vmimtAtomic();
// TMP[0] = MEM[reg1]
load(V850_TMP_WR(0), gpr_reg1, 0, 32, True, state->info.arch);
// TMP[1] = reg2 - TMP[0]
vmimtBinopRRR(V850_GPR_BITS, vmi_SUB, V850_TMP_WR(1), gpr_reg2, V850_TMP_RD(0), &flags_CoZrSiOv);
// if (TMP[1]==0) {
// MEM[reg1] = reg3;
// }
vmimtCompareRCJumpLabel(V850_GPR_BITS, vmi_COND_NE, V850_TMP_RD(1), 0, nostore);
store(gpr_reg3, gpr_reg1, 0, 32, True, state->info.arch);
vmimtInsertLabel(nostore);
// reg3 = TMP[0];
vmimtMoveRR(V850_GPR_BITS, gpr_reg3, V850_TMP_RD(0));
}
static void jarl2 (v850MorphStateP state, Uns8 lr, Uns8 tr) {
v850Addr pc = state->info.thisPC;
v850Addr isize = state->info.instrsize;
vmiReg gpr_lr = V850_GPR_WR(lr);
vmiReg gpr_tr = V850_GPR_WR(tr);
vmiJumpHint jump_hint = vmi_JH_NONE;
//
// indicate that this register may contain a link address
//
if (lr) {
jump_hint = vmi_JH_CALL;
state->v850->REG_RETMASK |= (1<<lr);
}
vmimtUncondJumpReg(pc+isize, gpr_tr, gpr_lr, jump_hint);
}
V850_MORPH_FN(morphCMOV_F12A) {
//
// Supported Architecture=V850_ISA_E1
//
// Uns8 b16 = state->info.b16;
Uns8 cccc = state->info.cccc;
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int16 simm = state->info.simm;
v850CondAction action = emitPrepareCondition(cccc);
if(action.op==ACO_ALWAYS) {
vmimtMoveRC(V850_GPR_BITS, gpr_reg3, simm);
} else {
vmimtCondMoveRCR(V850_GPR_BITS, action.flag, action.op==ACO_TRUE, gpr_reg3, simm, gpr_reg2);
}
}
V850_MORPH_FN(morphBSH_F12B) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
vmiReg reg2L = gpr_reg2;
vmiReg reg3L = gpr_reg3;
vmiReg reg2H = VMI_REG_DELTA(reg2L, 2);
vmiReg reg3H = VMI_REG_DELTA(reg3L, 2);
vmiReg reg3B0 = reg3L;
vmiReg reg3B1 = VMI_REG_DELTA(reg3L, 1);
// 16 bit byte swap
vmimtUnopRR(V850_GPR_BITS/2, vmi_SWP, reg3L, reg2L, &flags_Zr);
vmimtUnopRR(V850_GPR_BITS/2, vmi_SWP, reg3H, reg2H, &flags_Si);
// if reg3[7:0]==0 or reg3[15:8]==0 CY=1 - flagsZtoC
vmimtBinopRRC(V850_GPR_BITS/4, vmi_AND, VMI_NOREG, reg3B0, 0xff, &flags_CoFromZr);
vmimtBinopRRC(V850_GPR_BITS/4, vmi_AND, VMI_NOREG, reg3B1, 0xff, &flags_TmpFromZr);
vmimtBinopRR(V850_GPR_BITS/4, vmi_OR, V850_FLG_PSW_CO_WR, V850_TMP_RD(0), 0);
}
V850_MORPH_FN(morphBSW_F12B) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
vmiReg reg3B0 = gpr_reg3;
vmiReg reg3B1 = VMI_REG_DELTA(gpr_reg3, 1);
vmiReg reg3B2 = VMI_REG_DELTA(gpr_reg3, 2);
vmiReg reg3B3 = VMI_REG_DELTA(gpr_reg3, 3);
// This operation affects the Z and S flags
vmimtUnopRR(V850_GPR_BITS, vmi_SWP, gpr_reg3, gpr_reg2, &flags_ZrSi);
// Generate the carry flag by looking at the individual byte lanes
vmimtBinopRRC(V850_GPR_BITS/4, vmi_AND, VMI_NOREG, reg3B0, 0xff, &flags_CoFromZr);
vmimtBinopRRC(V850_GPR_BITS/4, vmi_AND, VMI_NOREG, reg3B1, 0xff, &flags_TmpFromZr);
vmimtBinopRR(V850_GPR_BITS/4, vmi_OR, V850_FLG_PSW_CO_WR, V850_TMP_RD(0), 0);
vmimtBinopRRC(V850_GPR_BITS/4, vmi_AND, VMI_NOREG, reg3B2, 0xff, &flags_TmpFromZr);
vmimtBinopRR(V850_GPR_BITS/4, vmi_OR, V850_FLG_PSW_CO_WR, V850_TMP_RD(0), 0);
vmimtBinopRRC(V850_GPR_BITS/4, vmi_AND, VMI_NOREG, reg3B3, 0xff, &flags_TmpFromZr);
vmimtBinopRR(V850_GPR_BITS/4, vmi_OR, V850_FLG_PSW_CO_WR, V850_TMP_RD(0), 0);
}
V850_MORPH_FN(morphHSH_F12B) {
//
// Supported Architecture=V850_ISA_E2
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
// reg3 <= reg2
// S <= (reg3[31]==1) ? 1 : 0
vmimtBinopRRC(V850_GPR_BITS, vmi_ADD, gpr_reg3, gpr_reg2, 0, &flags_Si);
// CY <= (reg3[15:0]==0) ? 1 : 0
// Z <= (reg3[15:0]==0) ? 1 : 0
vmimtBinopRRC(V850_GPR_BITS/2, vmi_AND, VMI_NOREG, gpr_reg2, 0xffff, &flags_Zr);
vmimtMoveRR(V850_GPR_BITS/4, V850_FLG_PSW_CO_WR, V850_FLG_PSW_ZR_RD);
// OV <= 0
vmimtMoveRC(V850_GPR_BITS/4, V850_FLG_PSW_OV_WR, 0);
}
V850_MORPH_FN(morphHSW_F12B) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
vmiReg reg2H = VMI_REG_DELTA(gpr_reg2, 2);
// Shift 2 bytes left
vmimtBinopRRC(V850_GPR_BITS, vmi_SHL, gpr_reg3, gpr_reg2, V850_GPR_BITS/2, 0);
// OR the two halfwords together
vmimtBinopRR(V850_GPR_BITS, vmi_OR, gpr_reg3, reg2H, &flags_ZrSi);
// if reg3[15:0]==0 or reg3[31:16]==0 CY=1 - flagsZtoC
vmimtBinopRRC(V850_GPR_BITS/2, vmi_AND, VMI_NOREG, gpr_reg2, 0xffff, &flags_CoFromZr);
vmimtBinopRRC(V850_GPR_BITS/2, vmi_AND, VMI_NOREG, reg2H, 0xffff, &flags_TmpFromZr);
vmimtBinopRR(V850_GPR_BITS/4, vmi_OR, V850_FLG_PSW_CO_WR, V850_TMP_RD(0), 0);
}
static void common_DISPOSE(Uns16 list12, Uns8 uimm5) {
memEndian endian = getEndian();
Int32 list12Iter;
Int32 spOffset = uimm5 * 4;
// vmiPrintf("common_DISPOSE list12=%08x uimm5=%02x\n", list12, uimm5);
// iterate over the bits in list12 inputting regs
// in [r31..r20]
for(list12Iter=31; list12Iter>=20; list12Iter--) {
if ((list12>>(list12Iter-20)) & 0x1) {
vmimtLoadRRO(V850_GPR_BITS, V850_GPR_BITS, spOffset, V850_GPR_WR(list12Iter), V850_GPR_RD(V850_GPR_SP), endian, False, True);
spOffset+=4;
}
}
vmimtBinopRC(V850_GPR_BITS, vmi_ADD, V850_GPR_WR(V850_GPR_SP), spOffset, 0);
}
V850_MORPH_FN(morphDISPOSE_F13IL1) {
//
// Supported Architecture=V850_ISA_E1
//
Uns16 list12 = state->info.list12;
Uns8 uimm5 = state->info.uimm5;
common_DISPOSE(list12, uimm5);
}
V850_MORPH_FN(morphDISPOSE_F13IL2) {
//
// Supported Architecture=V850_ISA_E1
//
Uns16 list12 = state->info.list12;
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 uimm5 = state->info.uimm5;
common_DISPOSE(list12, uimm5);
vmimtUncondJumpReg(0, gpr_reg1, VMI_NOREG, vmi_JH_RETURN);
}
static void common_PREPARE(Uns16 list12, Uns8 uimm5) {
memEndian endian = getEndian();
Int32 list12Iter;
Int32 spOffset = 0;
// vmiPrintf("common_PREPARE list12=%03x uimm5=%02x\n", list12, uimm5);
// iterate over the bits in list12 outputing regs
// in [r31..r20]
for(list12Iter=20; list12Iter<=31; list12Iter++) {
if (list12 & 0x1) {
spOffset-=4;
vmimtStoreRRO(V850_GPR_BITS, spOffset, V850_GPR_RD(V850_GPR_SP), V850_GPR_RD(list12Iter), endian, True);
}
list12 >>= 1;
}
vmimtBinopRC(V850_GPR_BITS, vmi_ADD, V850_GPR_WR(V850_GPR_SP), (spOffset - (uimm5 * 4)), 0);
}
V850_MORPH_FN(morphPREPARE_F13LI) {
//
// Supported Architecture=V850_ISA_E1
//
Uns8 uimm5 = state->info.uimm5;
Uns16 list12 = state->info.list12;
common_PREPARE(list12, uimm5);
}
V850_MORPH_FN(morphPREPARE_F13LI00) {
//
// Supported Architecture=V850_ISA_E1
//
Uns16 list12 = state->info.list12;
Uns8 uimm5 = state->info.uimm5;
common_PREPARE(list12, uimm5);
vmimtMoveRR(V850_GPR_BITS, V850_GPR_WR(V850_GPR_EP), V850_GPR_RD(V850_GPR_SP));
}
V850_MORPH_FN(morphPREPARE_F13LI01) {
//
// Supported Architecture=V850_ISA_E1
//
Uns16 list12 = state->info.list12;
Int32 simm = state->info.simm;
Uns8 uimm5 = state->info.uimm5;
common_PREPARE(list12, uimm5);
vmimtMoveRC(V850_GPR_BITS, V850_GPR_WR(V850_GPR_EP), simm);
}
V850_MORPH_FN(morphPREPARE_F13LI10) {
//
// Supported Architecture=V850_ISA_E1
//
Uns16 list12 = state->info.list12;
Int32 simm = state->info.simm;
Uns8 uimm5 = state->info.uimm5;
common_PREPARE(list12, uimm5);
vmimtMoveRC(V850_GPR_BITS, V850_GPR_WR(V850_GPR_EP), simm);
}
V850_MORPH_FN(morphPREPARE_F13LI11) {
//
// Supported Architecture=V850_ISA_E1
//
Uns16 list12 = state->info.list12;
Int32 simm = state->info.simm;
Uns8 uimm5 = state->info.uimm5;
common_PREPARE(list12, uimm5);
vmimtMoveRC(V850_GPR_BITS, V850_GPR_WR(V850_GPR_EP), simm);
}
//
// New for RH850
//
V850_MORPH_FN(morphLDL_W_F07D) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
vmimtAtomic();
//
// Set the reservation bit, addr & length
// This must be cleared on interrupt / exception
//
vmimtMoveRC(V850_FLG_LL_BITS, V850_FLG_LL, 1);
vmimtMoveRR(V850_REG_LL_BITS, V850_REG_LL, gpr_reg1);
load(gpr_reg3, gpr_reg1, 0, 32, True, state->info.arch);
}
V850_MORPH_FN(morphSTC_W_F07D) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
vmimtAtomic();
vmiLabelP FAIL = vmimtNewLabel();
vmiLabelP END = vmimtNewLabel();
//
// Test the state of the LL bit, before attempting the store
//
// if (FLG_LL) {
///* OK */
// MEM[ADDR] = Data;
// reg3 <= 1;
// } else {
///* FAIL */
// reg3 <= 0;
// }
///* END */
// FLG_LL <= 0
vmimtCompareRC(V850_FLG_TMP_BITS, vmi_COND_EQ, V850_FLG_LL, 0, V850_FLG_TMP_WR);
vmimtCondJumpLabel(V850_FLG_TMP_RD, True, FAIL);
//
// Perform Store - OK
//
store(gpr_reg3, gpr_reg1, 0, 32, True, state->info.arch);
vmimtMoveRC(V850_GPR_BITS, gpr_reg3, 1);
vmimtUncondJumpLabel(END);
//
// No Store - FAIL
//
vmimtInsertLabel(FAIL);
vmimtMoveRC(V850_GPR_BITS, gpr_reg3, 0);
vmimtInsertLabel(END);
vmimtMoveRC(V850_FLG_LL_BITS, V850_FLG_LL, 0);
}
static void common_BINS(v850MorphStateP state) {
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_WR(reg2);
Uns8 lsb = state->info.lsb;
Uns8 msb = state->info.msb;
Uns32 ones = 0xFFFFFFFF;
Uns32 maskr1 = VECINDEX(ones, (msb-lsb), 0, 0);
Uns32 maskr2 = ~(maskr1 << lsb);
vmimtBinopRRC(V850_GPR_BITS, vmi_AND, V850_TMP_WR(0), gpr_reg1, maskr1, 0);
vmimtBinopRC( V850_GPR_BITS, vmi_SHL, V850_TMP_WR(0), lsb, 0);
vmimtBinopRRC(V850_GPR_BITS, vmi_AND, V850_TMP_WR(1), gpr_reg2, maskr2, 0);
vmimtBinopRRR(V850_GPR_BITS, vmi_OR, gpr_reg2, V850_TMP_RD(0), V850_TMP_RD(1), &flags_ZrSiOv);
}
V850_MORPH_FN(morphBINS_F09RPWR_0) {
//
// Supported Architecture=ISA_E3
//
common_BINS(state);
}
V850_MORPH_FN(morphBINS_F09RPWR_1) {
//
// Supported Architecture=ISA_E3
//
common_BINS(state);
}
V850_MORPH_FN(morphBINS_F09RPWR_2) {
//
// Supported Architecture=ISA_E3
//
common_BINS(state);
}
V850_MORPH_FN(morphCLL_F10) {
//
// Supported Architecture=ISA_E3
//
vmimtMoveRC(8, V850_FLG_LL, 0);
}
V850_MORPH_FN(morphSNOOZE_F10) {
//
// Supported Architecture=ISA_E3
//
// NOP
}
V850_MORPH_FN(morphCACHE_F10) {
//
// Supported Architecture=ISA_E3
//
UM_PrivException(state);
}
V850_MORPH_FN(morphCACHE_CHBII) {
//
// Supported Architecture=ISA_E3
//
// NOP Operation in Supv & User Mode
}
V850_MORPH_FN(morphCACHE_CIBII) {
//
// Supported Architecture=ISA_E3
//
UM_PrivException(state);
}
V850_MORPH_FN(morphCACHE_CFALI) {
//
// Supported Architecture=ISA_E3
//
UM_PrivException(state);
}
V850_MORPH_FN(morphCACHE_CISTI) {
//
// Supported Architecture=ISA_E3
//
UM_PrivException(state);
}
V850_MORPH_FN(morphCACHE_CILDI) {
//
// Supported Architecture=ISA_E3
//
UM_PrivException(state);
}
V850_MORPH_FN(morphPREF_F10) {
//
// Supported Architecture=ISA_E3
//
UM_PrivException(state);
}
V850_MORPH_FN(morphPREFI_F10) {
//
// Supported Architecture=ISA_E3
//
UM_PrivException(state);
}
V850_MORPH_FN(morphPUSHSP_F11) {
//
// Supported Architecture=ISA_E3
//
Uns8 rh = state->info.reg1;
Uns8 rt = state->info.reg3;
memEndian endian = getEndian();
Int32 spOffset = 0;
if (rh <= rt) {
Uns8 cur = rh;
Uns8 end = rt;
while (cur <= end) {
spOffset-=4;
vmimtStoreRRO(V850_GPR_BITS, spOffset, V850_GPR_RD(V850_GPR_SP), V850_GPR_RD(cur), endian, True);
cur = cur+1;
}
vmimtBinopRC(V850_GPR_BITS, vmi_ADD, V850_GPR_WR(V850_GPR_SP), spOffset, 0);
}
}
V850_MORPH_FN(morphPOPSP_F11) {
//
// Supported Architecture=ISA_E3
//
Uns8 rh = state->info.reg1;
Uns8 rt = state->info.reg3;
memEndian endian = getEndian();
Int32 spOffset = 0;
if (rh <= rt) {
Uns8 cur = rt;
Uns8 end = rh;
while (cur >= end) {
vmimtLoadRRO(V850_GPR_BITS, V850_GPR_BITS, spOffset, V850_GPR_WR(cur), V850_GPR_RD(V850_GPR_SP), endian, False, True);
spOffset+=4;
cur = cur-1;
}
vmimtBinopRC(V850_GPR_BITS, vmi_ADD, V850_GPR_WR(V850_GPR_SP), spOffset, 0);
}
}
static void commonFlags_ROTL(v850MorphStateP state) {
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
// OV <= 0
vmimtMoveRC(V850_FLG_PSW_OV_BITS, V850_FLG_PSW_OV_WR, 0);
// CY = !(RESULT[0])
vmimtUnopRR( V850_FLG_PSW_CO_BITS, vmi_NOT, V850_FLG_PSW_CO_WR, gpr_reg3, 0);
vmimtBinopRC(V850_FLG_PSW_CO_BITS, vmi_AND, V850_FLG_PSW_CO_WR, 0x1, 0);
}
V850_MORPH_FN(morphROTL_F07RRR) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
vmimtBinopRRR(V850_GPR_BITS, vmi_ROL, gpr_reg3, gpr_reg2, gpr_reg1, &flags_CoZrSi);
commonFlags_ROTL(state);
}
V850_MORPH_FN(morphROTL_F07IRR) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg2 = state->info.reg2;
vmiReg gpr_reg2 = V850_GPR_RD(reg2);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Uns8 uimm5 = state->info.uimm5;
vmimtBinopRRC(V850_GPR_BITS, vmi_ROL, gpr_reg3, gpr_reg2, uimm5, &flags_CoZrSi);
commonFlags_ROTL(state);
}
V850_MORPH_FN(morphLD_DW_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
load(gpr_reg3, gpr_reg1, sdisp, 64, True, state->info.arch);
}
V850_MORPH_FN(morphST_DW_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
store(gpr_reg3, gpr_reg1, sdisp, 64, True, state->info.arch);
}
V850_MORPH_FN(morphBCOND_F07CC) {
//
// Supported Architecture=V850_ISA_E3
//
bcond(state);
}
V850_MORPH_FN(morphJARL_F11D) {
//
// Supported Architecture=V850_ISA_E3
//
// PC=GR[reg1]
// GR[reg3]=PC+4
Uns8 reg1 = state->info.reg1;
Uns8 reg3 = state->info.reg3;
jarl2(state, reg3, reg1);
}
// reg1 = reg1 - 1;
// if reg1 != 0
// PC = PC - udisp
V850_MORPH_FN(morphLOOP_F07RI) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
v850Addr targetPC = state->info.targetPC;
vmimtBinopRC(V850_GPR_BITS, vmi_SUB, gpr_reg1, 1, &flags_CoZrSiOv);
vmimtCondJump(V850_FLG_PSW_ZR_RD, False, 0, targetPC, VMI_NOREG, vmi_JH_RELATIVE);
}
V850_MORPH_FN(morphLD_BU_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
load(gpr_reg3, gpr_reg1, sdisp, 8, False, state->info.arch);
}
V850_MORPH_FN(morphLD_B_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
load(gpr_reg3, gpr_reg1, sdisp, 8, True, state->info.arch);
}
V850_MORPH_FN(morphLD_H_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
load(gpr_reg3, gpr_reg1, sdisp, 16, True, state->info.arch);
}
V850_MORPH_FN(morphLD_HU_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
load(gpr_reg3, gpr_reg1, sdisp, 16, False, state->info.arch);
}
V850_MORPH_FN(morphLD_W_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
load(gpr_reg3, gpr_reg1, sdisp, 32, True, state->info.arch);
}
V850_MORPH_FN(morphST_B_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
store(gpr_reg3, gpr_reg1, sdisp, 8, True, state->info.arch);
}
V850_MORPH_FN(morphST_H_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
store(gpr_reg3, gpr_reg1, sdisp, 16, True, state->info.arch);
}
V850_MORPH_FN(morphST_W_F14) {
//
// Supported Architecture=ISA_E3
//
Uns8 reg1 = state->info.reg1;
vmiReg gpr_reg1 = V850_GPR_RD(reg1);
Uns8 reg3 = state->info.reg3;
vmiReg gpr_reg3 = V850_GPR_WR(reg3);
Int32 sdisp = state->info.sdisp;
store(gpr_reg3, gpr_reg1, sdisp, 32, True, state->info.arch);
}
//
// Fix to 14606, correct VMMode during a syscall
//
static void vmicSYSCALL(v850P v850, Uns32 vector8) {
vmiProcessorP processor = (vmiProcessorP)v850;
Uns32 RETPC = vmirtGetPC(processor);
// EIPC <- PC
v850->SPR_EIPC.reg = RETPC + 4;
// EIPSW <- PSW
v850PackPSW(v850);
v850->SPR_EIPSW = v850->SPR_PSW;
// EIIC <- exception code
v850->SPR_EIIC.ECC = 0x8000 + vector8;
// PSW settings
v850->SPR_PSW.UM = 0;
v850->SPR_PSW.EP = 1;
v850->SPR_PSW.ID = 1;
v850UnPackPSW(v850);
// Set Mode
v850SetVMMode(v850);
Uns32 adr;
if (vector8 <= v850->SPR_SCCFG.SIZE) {
adr = v850->SPR_SCBP.reg + (vector8 << 2);
} else {
adr = v850->SPR_SCBP.reg;
}
// PC <- SCBP + mem(adr,Word)
memDomainP domain = vmirtGetProcessorDataDomain(processor);
Uns32 adrVal = vmirtRead4ByteDomain(domain, adr, getEndian(), MEM_AA_TRUE);
Uns32 PC = v850->SPR_SCBP.reg + adrVal;
vmirtSetPCException(processor, PC);
}
V850_MORPH_FN(morphSYSCALL_F10C) {
//
// Supported Architecture=ISA_E3
//
Uns8 vector8 = state->info.uimm;
vmimtArgProcessor();
vmimtArgUns32(vector8);
vmimtCallAttrs((vmiCallFn) vmicSYSCALL, VMCA_EXCEPTION);
}
V850_MORPH_FN(morphSYNCE_F01A) {
//
// Supported Architecture=ISA_E3
//
// NOP
}
V850_MORPH_FN(morphSYNCI_F01A) {
//
// Supported Architecture=ISA_E3
//
// NOP
}
| 27.299476 | 137 | 0.649872 |
78ea0091814345ef1b59c9b4a42b00e363dd9305 | 747 | h | C | KROSS/src/Kross/Renderer/Renderer.h | WillianKoessler/KROSS-ENGINE | 0e680b455ffd071565fe8b99343805ad16ca1e91 | [
"Apache-2.0"
] | null | null | null | KROSS/src/Kross/Renderer/Renderer.h | WillianKoessler/KROSS-ENGINE | 0e680b455ffd071565fe8b99343805ad16ca1e91 | [
"Apache-2.0"
] | null | null | null | KROSS/src/Kross/Renderer/Renderer.h | WillianKoessler/KROSS-ENGINE | 0e680b455ffd071565fe8b99343805ad16ca1e91 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "Kross/Core/Core.h"
#include "RendererAPI.h"
//#include "Cameras/Camera.h"
//#include "Shaders.h"
#include "RendererCommands.h"
namespace Kross {
class KAPI Renderer {
public:
static constexpr uint8_t TWO_D = 2;
static constexpr uint8_t THREE_D = 3;
static constexpr uint8_t VOXEL = 4;
static void Shutdown();
static void Init(uint8_t type);
//static void Submit(const Ref<Shader>& shader, const Ref<VertexArray>& va, const glm::mat4 transform = glm::mat4(1.0f));
//static void Submit(const Ref<Shader>& shader, const Scope<VertexArray>& va, const glm::mat4 transform = glm::mat4(1.0f));
inline static RendererAPI::API GetAPI() { return RendererAPI::GetAPI(); }
private:
static uint8_t s_uDims;
};
}
| 29.88 | 125 | 0.717537 |
2b9ff2dd0749a11d140afe1607b665417268c684 | 1,318 | h | C | src/sources/FilterCore.public_methods_declarations.h | Acidburn0zzz/oyranos | b87dcf0e7a88e9b2f5f6c2e3314ddbd3af045575 | [
"BSD-3-Clause"
] | 15 | 2015-03-06T07:21:55.000Z | 2021-12-31T02:07:10.000Z | src/sources/FilterCore.public_methods_declarations.h | Acidburn0zzz/oyranos | b87dcf0e7a88e9b2f5f6c2e3314ddbd3af045575 | [
"BSD-3-Clause"
] | 64 | 2015-02-09T11:07:32.000Z | 2022-03-26T13:03:05.000Z | src/sources/FilterCore.public_methods_declarations.h | Acidburn0zzz/oyranos | b87dcf0e7a88e9b2f5f6c2e3314ddbd3af045575 | [
"BSD-3-Clause"
] | 7 | 2015-05-23T23:17:04.000Z | 2021-06-24T13:27:30.000Z | OYAPI const char * OYEXPORT
oyFilterCore_GetCategory (
oyFilterCore_s * filter,
int nontranslated );
OYAPI const char * OYEXPORT
oyFilterCore_GetRegistration (
oyFilterCore_s * filter );
OYAPI const char * OYEXPORT
oyFilterCore_GetName ( oyFilterCore_s * filter,
oyNAME_e name_type );
OYAPI const char * OYEXPORT
oyFilterCore_GetText ( oyFilterCore_s * filter,
oyNAME_e name_type );
OYAPI oyFilterCore_s * OYEXPORT
oyFilterCore_NewWith ( const char * registration,
oyOptions_s * options,
oyObject_s object );
#include "oyPointer_s.h"
OYAPI oyPointer_s * OYEXPORT
oyFilterCore_GetBackendContext(
oyFilterCore_s * filter );
OYAPI int OYEXPORT
oyFilterCore_SetBackendContext(
oyFilterCore_s * filter,
oyPointer_s * data );
| 50.692308 | 75 | 0.444613 |
783baa6aba8bec0280767b77604d55908b8e7a55 | 483 | h | C | manager/PKPassManager.h | wwwins/objc-utils | fa2d5a8941c0c33a5bc8d862f8ac73c699445790 | [
"MIT"
] | 4 | 2015-09-06T08:45:12.000Z | 2016-03-28T06:16:20.000Z | manager/PKPassManager.h | wwwins/objc-utils | fa2d5a8941c0c33a5bc8d862f8ac73c699445790 | [
"MIT"
] | null | null | null | manager/PKPassManager.h | wwwins/objc-utils | fa2d5a8941c0c33a5bc8d862f8ac73c699445790 | [
"MIT"
] | null | null | null | //
// PKPassManager.h
//
// Created by wwwins on 2014/8/7.
// Copyright (c) 2014年 isobar. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PassKit/PassKit.h"
@interface PKPassManager : NSObject
@property (strong, nonatomic) PKPassLibrary *passLib;
+ (PKPassManager *)sharedManager;
- (void)showPassByIndex:(int)index;
- (void)showPassBySerialNumber:(NSString *)sn;
- (NSMutableArray *)getPassSerialNumberArrayExcludeWithArray:(NSArray *)excludeArray;
@end
| 21.954545 | 85 | 0.747412 |
4d9bce2a6985ec2c9c419ec1a6dccd8c6f766242 | 1,347 | c | C | First course/2nd semester/C-language start/2nd lab/lab_02_0_3.c | tekcellat/University | 9a0196a45c9cf33ac58018d636c3e4857eba0330 | [
"MIT"
] | null | null | null | First course/2nd semester/C-language start/2nd lab/lab_02_0_3.c | tekcellat/University | 9a0196a45c9cf33ac58018d636c3e4857eba0330 | [
"MIT"
] | null | null | null | First course/2nd semester/C-language start/2nd lab/lab_02_0_3.c | tekcellat/University | 9a0196a45c9cf33ac58018d636c3e4857eba0330 | [
"MIT"
] | 7 | 2020-12-04T07:26:46.000Z | 2022-03-08T17:47:47.000Z | //Вычисляет точное и приближенное значение функции f(x) = e^x с точностью eps
#include <stdio.h>
#include <math.h>
#define SUCCESS 0
#define UNSUCCESS 1
//Возвращает s - значение ряда в точке x с точностью eps
float series_value(float x, float eps)
{
float s = 0;
float last_term = 1; //последний посчитанный элемент ряда
for (int i = 1; last_term > eps; i++)
{
s += last_term;
last_term *= x / i; //вычисляем last_term - (i+1)-ый элемент
}
return s;
}
//Считывает число типа float
int read_number(float *const p)
{
if (scanf("%f", p) != 1)
{
printf("Input error");
return UNSUCCESS;
}
else
return SUCCESS;
}
int main(void)
{
float x;
float eps;
float s, f; //s - приближенное, f - точное значения функции
//Считываем данные
printf("x: ");
if (read_number(&x) == UNSUCCESS)
return UNSUCCESS;
printf("eps: ");
if (read_number(&eps) == UNSUCCESS)
return UNSUCCESS;
s = series_value(x, eps);
f = exp(x);
//Вывод результатов
printf("s(x) = %f\n", s);
printf("f(x) = %f\n", f);
printf("|f(x) - s(x)| = %f\n", fabs(f - s));
printf("|(f(x) - s(x))/f(x)| = %.3f %c", fabs((f - s) / f) * 100, '%');
return SUCCESS;
}
| 20.723077 | 78 | 0.533036 |
a23075d9d27776b5f3b274f77999e7d8be1665d5 | 207 | h | C | FlowLayout/FlowLayout/ViewController.h | chenchenlove/FlowLayout | e828f0c868288e77ab32d9f03ebf2d7b2f225d8d | [
"MIT"
] | null | null | null | FlowLayout/FlowLayout/ViewController.h | chenchenlove/FlowLayout | e828f0c868288e77ab32d9f03ebf2d7b2f225d8d | [
"MIT"
] | null | null | null | FlowLayout/FlowLayout/ViewController.h | chenchenlove/FlowLayout | e828f0c868288e77ab32d9f03ebf2d7b2f225d8d | [
"MIT"
] | null | null | null | //
// ViewController.h
// FlowLayout
//
// Created by smith on 16/4/27.
// Copyright © 2016年 smith. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
| 12.9375 | 49 | 0.681159 |
9e43a15428b1c68ba3ced315bd233e8f233dda49 | 2,323 | h | C | remoting/base/scoped_thread_proxy.h | Scopetta197/chromium | b7bf8e39baadfd9089de2ebdc0c5d982de4a9820 | [
"BSD-3-Clause"
] | 212 | 2015-01-31T11:55:58.000Z | 2022-02-22T06:35:11.000Z | remoting/base/scoped_thread_proxy.h | 1065672644894730302/Chromium | 239dd49e906be4909e293d8991e998c9816eaa35 | [
"BSD-3-Clause"
] | 5 | 2015-03-27T14:29:23.000Z | 2019-09-25T13:23:12.000Z | remoting/base/scoped_thread_proxy.h | 1065672644894730302/Chromium | 239dd49e906be4909e293d8991e998c9816eaa35 | [
"BSD-3-Clause"
] | 221 | 2015-01-07T06:21:24.000Z | 2022-02-11T02:51:12.000Z | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_BASE_SCOPED_THREAD_PROXY_H_
#define REMOTING_BASE_SCOPED_THREAD_PROXY_H_
#include "base/callback_forward.h"
#include "base/message_loop_proxy.h"
namespace remoting {
// ScopedThreadProxy is proxy for message loops that cancels all
// pending tasks when it is destroyed. It can be used to post tasks
// for a non-refcounted object. Must be deleted on the thread it
// belongs to.
//
//
// The main difference from WeakPtr<> is that this class can be used safely to
// post tasks from different threads.
// It is similar to WeakHandle<> used in sync: the main difference is
// that WeakHandle<> creates closures itself, while ScopedThreadProxy
// accepts base::Closure instances which caller needs to create using
// base::Bind().
//
// TODO(sergeyu): Potentially we could use WeakHandle<> instead of
// this class. Consider migrating to WeakHandle<> when it is moved to
// src/base and support for delayed tasks is implemented.
//
// Usage:
// class MyClass {
// public:
// MyClass()
// : thread_proxy_(base::MessageLoopProxy::current()) {}
//
// // Always called on the thread on which this object was created.
// void NonThreadSafeMethod() {}
//
// // Can be called on any thread.
// void ThreadSafeMethod() {
// thread_proxy_.PostTask(FROM_HERE, base::Bind(
// &MyClass::NonThreadSafeMethod, base::Unretained(this)));
// }
//
// private:
// ScopedThreadProxy thread_proxy_;
// };
class ScopedThreadProxy {
public:
ScopedThreadProxy(base::MessageLoopProxy* message_loop);
~ScopedThreadProxy();
void PostTask(const tracked_objects::Location& from_here,
const base::Closure& closure);
void PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& closure,
int64 delay_ms);
// Cancels all tasks posted via this proxy. Must be called on the
// thread this object belongs to.
void Detach();
private:
class Core;
scoped_refptr<Core> core_;
DISALLOW_COPY_AND_ASSIGN(ScopedThreadProxy);
};
} // namespace remoting
#endif // REMOTING_BASE_SCOPED_THREAD_PROXY_H_
| 31.391892 | 78 | 0.706845 |
9af3cba02a48e78078ae6f626da02a923c2da366 | 372 | h | C | PrivateFrameworks/CoreCDP.framework/CDPFollowUpController.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 36 | 2016-04-20T04:19:04.000Z | 2018-10-08T04:12:25.000Z | PrivateFrameworks/CoreCDP.framework/CDPFollowUpController.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | null | null | null | PrivateFrameworks/CoreCDP.framework/CDPFollowUpController.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 10 | 2016-06-16T02:40:44.000Z | 2019-01-15T03:31:45.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/CoreCDP.framework/CoreCDP
*/
@interface CDPFollowUpController : NSObject {
CDPDaemonConnection * _daemonConn;
}
- (void).cxx_destruct;
- (bool)clearFollowUpWithContext:(id)arg1 error:(id*)arg2;
- (id)init;
- (void)invalidate;
- (bool)postFollowUpWithContext:(id)arg1 error:(id*)arg2;
@end
| 23.25 | 69 | 0.75 |
fa4f0bfdf27ca47bbf374ea0c0ea818f3463f88f | 664 | h | C | csapex_math/include/csapex_math/serialization/binary_io.h | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 2 | 2016-09-02T15:33:22.000Z | 2019-05-06T22:09:33.000Z | csapex_math/include/csapex_math/serialization/binary_io.h | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 1 | 2021-02-14T19:53:30.000Z | 2021-02-14T19:53:30.000Z | csapex_math/include/csapex_math/serialization/binary_io.h | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 6 | 2016-10-12T00:55:23.000Z | 2021-02-10T17:49:25.000Z | #ifndef BINARY_IO_H
#define BINARY_IO_H
/// COMPONENT
#include <csapex_math/model/matrix.h>
#include <csapex_math/model/vector.h>
/// PROJECT
#include <csapex/serialization/serialization_buffer.h>
namespace csapex
{
SerializationBuffer& operator<<(SerializationBuffer& data, const math::linear::Vector& vector);
const SerializationBuffer& operator>>(const SerializationBuffer& data, math::linear::Vector& vector);
SerializationBuffer& operator<<(SerializationBuffer& data, const math::linear::Matrix& matrix);
const SerializationBuffer& operator>>(const SerializationBuffer& data, math::linear::Matrix& matrix);
} // namespace csapex
#endif // BINARY_IO_H
| 30.181818 | 101 | 0.784639 |
36981f3b39b0ad7ce982e9c50e24be1e9d07042d | 561 | h | C | Framer Inventory.sketchplugin/Contents/Sketch/RegisterInventory.framework/Versions/A/Headers/RegisterInventory.h | timurnurutdinov/export-states-for-framer | 9dbb6cb172e33c5ace3b0eec6343518893590624 | [
"Apache-2.0"
] | 305 | 2015-09-07T08:40:57.000Z | 2020-10-10T20:28:40.000Z | Framer Inventory.sketchplugin/Contents/Sketch/RegisterInventory.framework/Versions/A/Headers/RegisterInventory.h | timurnurutdinov/export-states-for-framer | 9dbb6cb172e33c5ace3b0eec6343518893590624 | [
"Apache-2.0"
] | 16 | 2015-09-13T19:08:55.000Z | 2018-03-09T16:51:07.000Z | Framer Inventory.sketchplugin/Contents/Sketch/RegisterInventory.framework/Versions/A/Headers/RegisterInventory.h | timurnurutdinov/export-states-for-framer | 9dbb6cb172e33c5ace3b0eec6343518893590624 | [
"Apache-2.0"
] | 12 | 2015-09-07T09:36:30.000Z | 2018-02-14T16:33:35.000Z | //
// RegisterInventory.h
// RegisterInventory
//
// Created by Timur Nurutdinov on 2/18/17.
// Copyright © 2017 Timur Nurutdinov. All rights reserved.
//
#import <Cocoa/Cocoa.h>
//! Project version number for RegisterInventory.
FOUNDATION_EXPORT double RegisterInventoryVersionNumber;
//! Project version string for RegisterInventory.
FOUNDATION_EXPORT const unsigned char RegisterInventoryVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <RegisterInventory/PublicHeader.h>
| 28.05 | 142 | 0.786096 |
d2513ab13d4b084806b3b88d44ffcb062bf08833 | 424,449 | h | C | proteus/mprans/RANS3PF2D.h | acatwithacomputer/proteus | 80dfad95da6ab4d18a88a035f55c26b03540a864 | [
"MIT"
] | null | null | null | proteus/mprans/RANS3PF2D.h | acatwithacomputer/proteus | 80dfad95da6ab4d18a88a035f55c26b03540a864 | [
"MIT"
] | null | null | null | proteus/mprans/RANS3PF2D.h | acatwithacomputer/proteus | 80dfad95da6ab4d18a88a035f55c26b03540a864 | [
"MIT"
] | null | null | null | #ifndef RANS3PF2D_H
#define RANS3PF2D_H
#include <cmath>
#include <valarray>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include "CompKernel.h"
#include "ModelFactory.h"
#include "SedClosure.h"
#include "equivalent_polynomials.h"
#include "ArgumentsDict.h"
const double DM=0.0;//1-mesh conservation and divergence, 0 - weak div(v) only
const double DM2=0.0;//1-point-wise mesh volume strong-residual, 0 - div(v) only
const double DM3=1.0;//1-point-wise divergence, 0-point-wise rate of volume change
#define DRAG_FAC 1.0
#define TURB_FORCE_FAC 0.0
#define CUT_CELL_INTEGRATION 0
double sgn(double val) {
return double((0.0 < val) - (val < 0.0));
}
//////////////////////
// ***** TODO ***** //
//////////////////////
// *fix the following w.r.t. not dividing momentum eqn by rho
// * updateSolidParticleTerms
// *Double check the following w.r.t. not dividing momentum eqn by rho
// * updateDarcyForchheimerTerms_Ergun
// * updateTurbulenceClosure
// * check pdeResidual_p. In particular check the term with q_dvos_dt
// * double check exteriorNumericalAdvectiveFlux. I multiply from outside porosity*rho
// * MOVING MESH. Double check.
// * Turbulence: double check eddy_viscosity within evaluateCoefficients
// ***** END OF TODO *****
#define CELL_BASED_EV_COEFF 1
#define POWER_SMOOTHNESS_INDICATOR 2
#define EPS_FOR_GAMMA_INDICATOR 1E-10
#define C_FOR_GAMMA_INDICATOR 0.25 // increase gamma to make the indicator more agressive (less dissipative)
#define USE_GAMMA_INDICATOR 0
#define ANISOTROPIC_DIFFUSION 0
inline void baryCoords(const double r0[2],
const double r1[2],
const double r2[2],
const double r[2],
double* lambda)
{
double detT = (r1[1] - r2[1])*(r0[0] - r2[0]) + (r2[0] - r1[0])*(r0[1] - r2[1]);
lambda[0] = ((r1[1] - r2[1])*(r[0] - r2[0]) + (r2[0] - r1[0])*(r[1] - r2[1]))/detT;
lambda[1] = ((r2[1] - r0[1])*(r[0] - r2[0]) + (r0[0] - r2[0])*(r[1] - r2[1]))/detT;
lambda[2] = 1.0 - lambda[0] - lambda[1];
}
namespace proteus
{
template<int nSpace, int nP, int nQ, int nEBQ>
using GeneralizedFunctions = equivalent_polynomials::GeneralizedFunctions_mix<nSpace, nP, nQ, nEBQ>;
class cppRANS3PF2D_base
{
public:
std::valarray<double> TransportMatrix, TransposeTransportMatrix;
std::valarray<double> uStar_psi, vStar_psi, wStar_psi;
std::valarray<double> uStar_hi, vStar_hi, wStar_hi, den_hi;
std::valarray<double> uStar_min_hiHe, vStar_min_hiHe, wStar_min_hiHe;
std::valarray<double> uStar_gamma, vStar_gamma, wStar_gamma;
virtual ~cppRANS3PF2D_base() {}
virtual void setSedClosure(double aDarcy,
double betaForch,
double grain,
double packFraction,
double packMargin,
double maxFraction,
double frFraction,
double sigmaC,
double C3e,
double C4e,
double eR,
double fContact,
double mContact,
double nContact,
double angFriction,
double vos_limiter,
double mu_fr_limiter
) {}
virtual void calculateResidual(arguments_dict& args,
bool useExact
)=0;
virtual void calculateJacobian(arguments_dict& args,
bool useExact)=0;
virtual void calculateVelocityAverage(arguments_dict& args) = 0;
virtual void getBoundaryDOFs(arguments_dict& args)=0;
};
template<class CompKernelType,
int nSpace,
int nQuadraturePoints_element,
int nDOF_mesh_trial_element,
int nDOF_trial_element,
int nDOF_test_element,
int nQuadraturePoints_elementBoundary>
class cppRANS3PF2D : public cppRANS3PF2D_base
{
public:
std::vector<int> surrogate_boundaries, surrogate_boundary_elements, surrogate_boundary_particle;
std::valarray<double> TransportMatrix, TransposeTransportMatrix, psi;
double C_sbm, beta_sbm;
cppHsuSedStress<2> closure;
const int nDOF_test_X_trial_element,
nSpace2;
CompKernelType ck;
GeneralizedFunctions<nSpace,1,nQuadraturePoints_element,nQuadraturePoints_elementBoundary> gf;
GeneralizedFunctions<nSpace,1,nQuadraturePoints_element,nQuadraturePoints_elementBoundary> gf_s;
cppRANS3PF2D():
nSpace2(4),
closure(150.0,
0.0,
0.0102,
0.2,
0.01,
0.635,
0.57,
1.1,
1.2,
1.0,
0.8,
0.02,
2.0,
5.0,
M_PI/6., 0.05, 1.00),
nDOF_test_X_trial_element(nDOF_test_element*nDOF_trial_element),
ck(),
C_sbm(10.0),
beta_sbm(0.0)
{/* std::cout<<"Constructing cppRANS3PF2D<CompKernelTemplate<"
<<0<<","
<<0<<","
<<0<<","
<<0<<">,"*/
/* <<nSpaceIn<<","
<<nQuadraturePoints_elementIn<<","
<<nDOF_mesh_trial_elementIn<<","
<<nDOF_trial_elementIn<<","
<<nDOF_test_elementIn<<","
<<nQuadraturePoints_elementBoundaryIn<<">());"*/
/* <<std::endl<<std::flush; */
}
void setSedClosure(double aDarcy,
double betaForch,
double grain,
double packFraction,
double packMargin,
double maxFraction,
double frFraction,
double sigmaC,
double C3e,
double C4e,
double eR,
double fContact,
double mContact,
double nContact,
double angFriction,
double vos_limiter,
double mu_fr_limiter)
{
closure = cppHsuSedStress<2>(aDarcy,
betaForch,
grain,
packFraction,
packMargin,
maxFraction,
frFraction,
sigmaC,
C3e,
C4e,
eR,
fContact,
mContact,
nContact,
angFriction,
vos_limiter,
mu_fr_limiter);
}
inline double Dot(const double vec1[nSpace],
const double vec2[nSpace])
{
double dot = 0;
for (int I=0; I<nSpace; I++)
dot += vec1[I]*vec2[I];
return dot;
}
inline void calculateTangentialGradient(const double normal[nSpace],
const double vel_grad[nSpace],
double vel_tgrad[nSpace])
{
double normal_dot_vel_grad = Dot(normal,vel_grad);
for (int I=0; I<nSpace; I++)
vel_tgrad[I] = vel_grad[I] - normal_dot_vel_grad*normal[I];
}
inline
void evaluateCoefficients(const double eps_rho,
const double eps_mu,
const double eps_s,
const double sigma,
const double rho_0,
double nu_0,
const double rho_1,
double nu_1,
const double h_e,
const double smagorinskyConstant,
const int turbulenceClosureModel,
const double g[nSpace],
const double useVF,
const double& vf,
const double& phi,
const double n[nSpace],
const double distance_to_omega_solid,
const double& kappa,
const double porosity,//VRANS specific
const double& p,
const double grad_p[nSpace],
const double grad_u[nSpace],
const double grad_v[nSpace],
const double grad_w[nSpace],
const double& u,
const double& v,
const double& w,
const double& uStar,
const double& vStar,
const double& wStar,
double& eddy_viscosity,
double& mom_u_acc,
double& dmom_u_acc_u,
double& mom_v_acc,
double& dmom_v_acc_v,
double& mom_w_acc,
double& dmom_w_acc_w,
double mass_adv[nSpace],
double dmass_adv_u[nSpace],
double dmass_adv_v[nSpace],
double dmass_adv_w[nSpace],
double mom_u_adv[nSpace],
double dmom_u_adv_u[nSpace],
double dmom_u_adv_v[nSpace],
double dmom_u_adv_w[nSpace],
double mom_v_adv[nSpace],
double dmom_v_adv_u[nSpace],
double dmom_v_adv_v[nSpace],
double dmom_v_adv_w[nSpace],
double mom_w_adv[nSpace],
double dmom_w_adv_u[nSpace],
double dmom_w_adv_v[nSpace],
double dmom_w_adv_w[nSpace],
double mom_uu_diff_ten[nSpace],
double mom_vv_diff_ten[nSpace],
double mom_ww_diff_ten[nSpace],
double mom_uv_diff_ten[1],
double mom_uw_diff_ten[1],
double mom_vu_diff_ten[1],
double mom_vw_diff_ten[1],
double mom_wu_diff_ten[1],
double mom_wv_diff_ten[1],
double& mom_u_source,
double& mom_v_source,
double& mom_w_source,
double& mom_u_ham,
double dmom_u_ham_grad_p[nSpace],
double dmom_u_ham_grad_u[nSpace],
double& mom_v_ham,
double dmom_v_ham_grad_p[nSpace],
double dmom_v_ham_grad_v[nSpace],
double& mom_w_ham,
double dmom_w_ham_grad_p[nSpace],
double dmom_w_ham_grad_w[nSpace],
double& rhoSave,
double& nuSave,
int KILL_PRESSURE_TERM,
int MULTIPLY_EXTERNAL_FORCE_BY_DENSITY,
double forcex,
double forcey,
double forcez,
int MATERIAL_PARAMETERS_AS_FUNCTION,
double density_as_function,
double dynamic_viscosity_as_function,
int USE_SBM,
double x, double y, double z,
int use_ball_as_particle,
double* ball_center,
double* ball_radius,
double* ball_velocity,
double* ball_angular_velocity,
// int by parts pressure
int INT_BY_PARTS_PRESSURE)
{
double rho,nu,mu,H_rho,ImH_rho,d_rho,H_mu,ImH_mu,d_mu,norm_n,nu_t0=0.0,nu_t1=0.0,nu_t;
H_rho = (1.0-useVF)*gf.H(eps_rho,phi) + useVF*fmin(1.0,fmax(0.0,vf));
ImH_rho = (1.0-useVF)*gf.ImH(eps_rho,phi) + useVF*(1.0-fmin(1.0,fmax(0.0,vf)));
d_rho = (1.0-useVF)*gf.D(eps_rho,phi);
H_mu = (1.0-useVF)*gf.H(eps_mu,phi) + useVF*fmin(1.0,fmax(0.0,vf));
ImH_mu = (1.0-useVF)*gf.ImH(eps_mu,phi) + useVF*(1.0-fmin(1.0,fmax(0.0,vf)));
d_mu = (1.0-useVF)*gf.D(eps_mu,phi);
//calculate eddy viscosity
switch (turbulenceClosureModel)
{
double norm_S;
case 1:
{
norm_S = sqrt(2.0*(grad_u[0]*grad_u[0] + grad_v[1]*grad_v[1] + //grad_w[2]*grad_w[2] +
0.5*(grad_u[1]+grad_v[0])*(grad_u[1]+grad_v[0])));
nu_t0 = smagorinskyConstant*smagorinskyConstant*h_e*h_e*norm_S;
nu_t1 = smagorinskyConstant*smagorinskyConstant*h_e*h_e*norm_S;
}
case 2:
{
double re_0,cs_0=0.0,re_1,cs_1=0.0;
norm_S = sqrt(2.0*(grad_u[0]*grad_u[0] + grad_v[1]*grad_v[1] +//grad_w[2]*grad_w[2] +
0.5*(grad_u[1]+grad_v[0])*(grad_u[1]+grad_v[0])));
re_0 = h_e*h_e*norm_S/nu_0;
if (re_0 > 1.0)
cs_0=0.027*pow(10.0,-3.23*pow(re_0,-0.92));
nu_t0 = cs_0*h_e*h_e*norm_S;
re_1 = h_e*h_e*norm_S/nu_1;
if (re_1 > 1.0)
cs_1=0.027*pow(10.0,-3.23*pow(re_1,-0.92));
nu_t1 = cs_1*h_e*h_e*norm_S;
}
}
if (MATERIAL_PARAMETERS_AS_FUNCTION==0)
{
rho = rho_0*ImH_rho+rho_1*H_rho;
nu_t= nu_t0*ImH_mu+nu_t1*H_mu;
nu = nu_0*ImH_mu+nu_1*H_mu;
nu += nu_t;
mu = rho_0*nu_0*ImH_mu+rho_1*nu_1*H_mu;
}
else // set the material parameters by a function. To check convergence
{
rho = density_as_function;
nu_t= 0;
mu = dynamic_viscosity_as_function;
nu = mu/rho;
}
rhoSave = rho;
nuSave = nu;
eddy_viscosity = nu_t*rho; // mql. CHECK. Most changes about not divide by rho are here
// mass (volume accumulation)
//..hardwired
double phi_s_effect = (distance_to_omega_solid > 0.0) ? 1.0 : 1e-10;
if(USE_SBM>0)
phi_s_effect = 1.0;
//u momentum accumulation
mom_u_acc=u;//trick for non-conservative form
dmom_u_acc_u=phi_s_effect * rho*porosity;
//v momentum accumulation
mom_v_acc=v;
dmom_v_acc_v=phi_s_effect * rho*porosity;
/* //w momentum accumulation */
/* mom_w_acc=phi_s_effect*w; */
/* dmom_w_acc_w=phi_s_effect*rho*porosity; */
//mass advective flux
mass_adv[0]=phi_s_effect * porosity*u;
mass_adv[1]=phi_s_effect * porosity*v;
/* mass_adv[2]=phi_s_effect * porosity*w; */
dmass_adv_u[0]=phi_s_effect * porosity;
dmass_adv_u[1]=0.0;
/* dmass_adv_u[2]=0.0; */
dmass_adv_v[0]=0.0;
dmass_adv_v[1]=phi_s_effect * porosity;
/* dmass_adv_v[2]=0.0; */
/* dmass_adv_w[0]=0.0; */
/* dmass_adv_w[1]=0.0; */
/* dmass_adv_w[2]=phi_s_effect * porosity; */
//advection switched to non-conservative form but could be used for mesh motion...
//u momentum advective flux
mom_u_adv[0]=0.0;
mom_u_adv[1]=0.0;
/* mom_u_adv[2]=0.0; */
dmom_u_adv_u[0]=0.0;
dmom_u_adv_u[1]=0.0;
/* dmom_u_adv_u[2]=0.0; */
dmom_u_adv_v[0]=0.0;
dmom_u_adv_v[1]=0.0;
/* dmom_u_adv_v[2]=0.0; */
/* dmom_u_adv_w[0]=0.0; */
/* dmom_u_adv_w[1]=0.0; */
/* dmom_u_adv_w[2]=0.0; */
//v momentum advective_flux
mom_v_adv[0]=0.0;
mom_v_adv[1]=0.0;
/* mom_v_adv[2]=0.0; */
dmom_v_adv_u[0]=0.0;
dmom_v_adv_u[1]=0.0;
/* dmom_v_adv_u[2]=0.0; */
/* dmom_v_adv_w[0]=0.0; */
/* dmom_v_adv_w[1]=0.0; */
/* dmom_v_adv_w[2]=0.0; */
dmom_v_adv_v[0]=0.0;
dmom_v_adv_v[1]=0.0;
/* dmom_v_adv_v[2]=0.0; */
/* //w momentum advective_flux */
/* mom_w_adv[0]=0.0; */
/* mom_w_adv[1]=0.0; */
/* mom_w_adv[2]=0.0; */
/* dmom_w_adv_u[0]=0.0; */
/* dmom_w_adv_u[1]=0.0; */
/* dmom_w_adv_u[2]=0.0; */
/* dmom_w_adv_v[0]=0.0; */
/* dmom_w_adv_v[1]=0.0; */
/* dmom_w_adv_v[2]=0.0; */
/* dmom_w_adv_w[0]=0.0; */
/* dmom_w_adv_w[1]=0.0; */
/* dmom_w_adv_w[2]=0.0; */
//u momentum diffusion tensor
mom_uu_diff_ten[0] = phi_s_effect * porosity*2.0*mu;
mom_uu_diff_ten[1] = phi_s_effect * porosity*mu;
/* mom_uu_diff_ten[2] = phi_s_effect * porosity*mu; */
mom_uv_diff_ten[0]=phi_s_effect * porosity*mu;
/* mom_uw_diff_ten[0]=phi_s_effect * porosity*mu; */
//v momentum diffusion tensor
mom_vv_diff_ten[0] = phi_s_effect * porosity*mu;
mom_vv_diff_ten[1] = phi_s_effect * porosity*2.0*mu;
/* mom_vv_diff_ten[2] = phi_s_effect * porosity*mu; */
mom_vu_diff_ten[0]=phi_s_effect * porosity*mu;
/* mom_vw_diff_ten[0]=phi_s_effect * porosity*mu; */
/* //w momentum diffusion tensor */
/* mom_ww_diff_ten[0] = phi_s_effect * porosity*mu; */
/* mom_ww_diff_ten[1] = phi_s_effect * porosity*mu; */
/* mom_ww_diff_ten[2] = phi_s_effect * porosity*2.0*mu; */
/* mom_wu_diff_ten[0]=phi_s_effect * porosity*mu; */
/* mom_wv_diff_ten[0]=phi_s_effect * orosity*mu; */
//momentum sources
norm_n = sqrt(n[0]*n[0]+n[1]*n[1]);//+n[2]*n[2]);
mom_u_source = -phi_s_effect * porosity*rho*g[0];// - porosity*d_mu*sigma*kappa*n[0]/(rho*(norm_n+1.0e-8));
mom_v_source = -phi_s_effect * porosity*rho*g[1];// - porosity*d_mu*sigma*kappa*n[1]/(rho*(norm_n+1.0e-8));
/* mom_w_source = -porosity*rho*g[2];// - porosity*d_mu*sigma*kappa*n[2]/(rho*(norm_n+1.0e-8)); */
// mql: add general force term
mom_u_source -= (MULTIPLY_EXTERNAL_FORCE_BY_DENSITY == 1 ? porosity*rho : 1.0)*forcex;
mom_v_source -= (MULTIPLY_EXTERNAL_FORCE_BY_DENSITY == 1 ? porosity*rho : 1.0)*forcey;
/* mom_w_source -= forcez; */
//u momentum Hamiltonian (pressure)
double aux_pressure = (KILL_PRESSURE_TERM==1 ? 0. : 1.)*(INT_BY_PARTS_PRESSURE==1 ? 0. : 1.);
mom_u_ham = phi_s_effect * porosity*grad_p[0]*aux_pressure;
dmom_u_ham_grad_p[0]=phi_s_effect * porosity*aux_pressure;
dmom_u_ham_grad_p[1]=0.0;
/* dmom_u_ham_grad_p[2]=0.0; */
//v momentum Hamiltonian (pressure)
mom_v_ham = phi_s_effect * porosity*grad_p[1]*aux_pressure;
dmom_v_ham_grad_p[0]=0.0;
dmom_v_ham_grad_p[1]=phi_s_effect * porosity*aux_pressure;
/* dmom_v_ham_grad_p[2]=0.0; */
/* //w momentum Hamiltonian (pressure) */
/* mom_w_ham = porosity*grad_p[2]; */
/* dmom_w_ham_grad_p[0]=0.0; */
/* dmom_w_ham_grad_p[1]=0.0; */
/* dmom_w_ham_grad_p[2]=porosity; */
//u momentum Hamiltonian (advection)
mom_u_ham += phi_s_effect * porosity*rho*(uStar*grad_u[0]+vStar*grad_u[1]);
dmom_u_ham_grad_u[0]=phi_s_effect * porosity*rho*uStar;
dmom_u_ham_grad_u[1]=phi_s_effect * porosity*rho*vStar;
/* dmom_u_ham_grad_u[2]=porosity*rho*wStar; */
//v momentum Hamiltonian (advection)
mom_v_ham += phi_s_effect * porosity*rho*(uStar*grad_v[0]+vStar*grad_v[1]);
dmom_v_ham_grad_v[0]=phi_s_effect * porosity*rho*uStar;
dmom_v_ham_grad_v[1]=phi_s_effect * porosity*rho*vStar;
/* dmom_v_ham_grad_v[2]=porosity*rho*wStar; */
/* //w momentum Hamiltonian (advection) */
/* mom_w_ham += porosity*rho*(uStar*grad_w[0]+vStar*grad_w[1]+wStar*grad_w[2]); */
/* dmom_w_ham_grad_w[0]=porosity*rho*uStar; */
/* dmom_w_ham_grad_w[1]=porosity*rho*vStar; */
/* dmom_w_ham_grad_w[2]=porosity*rho*wStar; */
}
//VRANS specific
inline
void updateDarcyForchheimerTerms_Ergun(/* const double linearDragFactor, */
/* const double nonlinearDragFactor, */
/* const double porosity, */
/* const double meanGrainSize, */
const double alpha,
const double beta,
const double eps_rho,
const double eps_mu,
const double rho_0,
const double nu_0,
const double rho_1,
const double nu_1,
double nu_t,
const double useVF,
const double vf,
const double phi,
const double u,
const double v,
const double w,
const double uStar,
const double vStar,
const double wStar,
const double eps_s,
const double phi_s,
const double u_s,
const double v_s,
const double w_s,
const double uStar_s,
const double vStar_s,
const double wStar_s,
double& mom_u_source,
double& mom_v_source,
double& mom_w_source,
double dmom_u_source[nSpace],
double dmom_v_source[nSpace],
double dmom_w_source[nSpace],
double gradC_x,
double gradC_y,
double gradC_z)
{
double rho, mu,nu,H_mu,ImH_mu,uc,duc_du,duc_dv,duc_dw,viscosity,H_s;
H_mu = (1.0-useVF)*gf.H(eps_mu,phi)+useVF*fmin(1.0,fmax(0.0,vf));
ImH_mu = (1.0-useVF)*gf.ImH(eps_mu,phi)+useVF*(1.0-fmin(1.0,fmax(0.0,vf)));
nu = nu_0*ImH_mu+nu_1*H_mu;
rho = rho_0*ImH_mu+rho_1*H_mu;
mu = rho_0*nu_0*ImH_mu+rho_1*nu_1*H_mu;
viscosity = nu;
uc = sqrt(u*u+v*v*+w*w);
duc_du = u/(uc+1.0e-12);
duc_dv = v/(uc+1.0e-12);
duc_dw = w/(uc+1.0e-12);
double fluid_velocity[2]={uStar,vStar}, solid_velocity[2]={uStar_s,vStar_s};
double new_beta = closure.betaCoeff(1.0-phi_s,
rho,
fluid_velocity,
solid_velocity,
viscosity)*DRAG_FAC;
//new_beta = 254800.0;//hack fall velocity of 0.1 with no pressure gradient
double beta2 = 156976.4;//hack, fall velocity of 0.1 with hydrostatic water
mom_u_source += (1.0 - phi_s) * new_beta * (u - u_s) - TURB_FORCE_FAC*new_beta*nu_t*gradC_x/closure.sigmaC_ +
(1.0 - phi_s)*(1.0-DRAG_FAC)*beta2*(u-u_s);
mom_v_source += (1.0 - phi_s) * new_beta * (v - v_s) - TURB_FORCE_FAC*new_beta*nu_t*gradC_y/closure.sigmaC_ +
(1.0 - phi_s)*(1.0-DRAG_FAC)*beta2*(v-v_s);
/* mom_w_source += phi_s*new_beta*(w-w_s); */
dmom_u_source[0] = (1.0 - phi_s) * new_beta + (1.0 - phi_s)*(1.0-DRAG_FAC)*beta2;
dmom_u_source[1] = 0.0;
/* dmom_u_source[2] = 0.0; */
dmom_v_source[0] = 0.0;
dmom_v_source[1] = (1.0 - phi_s) * new_beta + (1.0 - phi_s)*(1.0-DRAG_FAC)*beta2;
/*dmom_v_source[2] = 0.0; */
dmom_w_source[0] = 0.0;
dmom_w_source[1] = 0.0;
/*dmom_w_source[2] = (1.0 - phi_s) * new_beta; */
}
inline void updateSolidParticleTerms(bool element_owned,
const double particle_nitsche,
const double dV,
const int nParticles,
const int sd_offset,
double *particle_signed_distances,
double *particle_signed_distance_normals,
double *particle_velocities,
double *particle_centroids,
int use_ball_as_particle,
double* ball_center,
double* ball_radius,
double* ball_velocity,
double* ball_angular_velocity,
const double porosity, //VRANS specific
const double penalty,
const double alpha,
const double beta,
const double eps_rho,
const double eps_mu,
const double rho_0,
const double nu_0,
const double rho_1,
const double nu_1,
const double useVF,
const double vf,
const double phi,
const double x,
const double y,
const double z,
const double p,
const double u,
const double v,
const double w,
const double uStar,
const double vStar,
const double wStar,
const double eps_s,
const double grad_u[nSpace],
const double grad_v[nSpace],
const double grad_w[nSpace],
double &mom_u_source,
double &mom_v_source,
double &mom_w_source,
double dmom_u_source[nSpace],
double dmom_v_source[nSpace],
double dmom_w_source[nSpace],
double mom_u_adv[nSpace],
double mom_v_adv[nSpace],
double mom_w_adv[nSpace],
double dmom_u_adv_u[nSpace],
double dmom_v_adv_v[nSpace],
double dmom_w_adv_w[nSpace],
double &mom_u_ham,
double dmom_u_ham_grad_u[nSpace],
double &mom_v_ham,
double dmom_v_ham_grad_v[nSpace],
double &mom_w_ham,
double dmom_w_ham_grad_w[nSpace],
double *particle_netForces,
double *particle_netMoments,
double *particle_surfaceArea)
{
double C, rho, mu, nu, H_mu, ImH_mu, uc, duc_du, duc_dv, duc_dw, H_s, D_s, phi_s, u_s, v_s, w_s;
double force_x, force_y, r_x, r_y, force_p_x, force_p_y, force_stress_x, force_stress_y;
double phi_s_normal[2]={0.0};
double fluid_outward_normal[2];
double vel[2];
double center[2];
H_mu = (1.0 - useVF) * gf.H(eps_mu, phi) + useVF * fmin(1.0, fmax(0.0, vf));
ImH_mu = (1.0 - useVF) * gf.ImH(eps_mu, phi) + useVF * (1.0-fmin(1.0, fmax(0.0, vf)));
nu = nu_0 * ImH_mu + nu_1 * H_mu;
rho = rho_0 * ImH_mu + rho_1 * H_mu;
mu = rho_0 * nu_0 * ImH_mu + rho_1 * nu_1 * H_mu;
C = 0.0;
for (int i = 0; i < nParticles; i++)
{
double* vel_pointer= &particle_velocities[i*sd_offset*nSpace];
if(use_ball_as_particle==1)
{
get_distance_to_ith_ball(nParticles,ball_center,ball_radius,i,x,y,z,phi_s);
get_normal_to_ith_ball(nParticles,ball_center,ball_radius,i,x,y,z,phi_s_normal[0],phi_s_normal[1]);
get_velocity_to_ith_ball(nParticles,ball_center,ball_radius,
ball_velocity,ball_angular_velocity,
i,x,y,z,
vel[0],vel[1]);
center[0] = ball_center[3*i+0];
center[1] = ball_center[3*i+1];
u_s = vel[0];
v_s = vel[1];
}
else
{
phi_s = particle_signed_distances[i * sd_offset];
phi_s_normal[0] = particle_signed_distance_normals[i * sd_offset * 3 + 0];
phi_s_normal[1] = particle_signed_distance_normals[i * sd_offset * 3 + 1];
vel[0] = particle_velocities[i * sd_offset * 3 + 0];
vel[1] = particle_velocities[i * sd_offset * 3 + 1];
u_s = vel_pointer[0];
v_s = vel_pointer[1];
center[0] = particle_centroids[3*i+0];
center[1] = particle_centroids[3*i+1];
}
fluid_outward_normal[0] = -phi_s_normal[0];
fluid_outward_normal[1] = -phi_s_normal[1];
w_s = 0;
H_s = gf_s.H(eps_s, phi_s);
D_s = gf_s.D(eps_s, phi_s);
double rel_vel_norm = sqrt((uStar - u_s) * (uStar - u_s) +
(vStar - v_s) * (vStar - v_s) +
(wStar - w_s) * (wStar - w_s));
// double C_surf = (phi_s > 0.0) ? 0.0 : nu * penalty;
//double C_vol = (phi_s > 0.0) ? 0.0 : (alpha + beta * rel_vel_norm);
double C_surf = mu * penalty;
double C_vol = (alpha + beta * rel_vel_norm);
C = (D_s * C_surf + gf_s.ImH(eps_s, phi_s) * C_vol);
force_x = dV * D_s * (p * fluid_outward_normal[0]
- porosity*mu*(fluid_outward_normal[0] * 2* grad_u[0] +
fluid_outward_normal[1] * (grad_u[1]+grad_v[0]))
+C_surf*(u-u_s)*rho
);
force_y = dV * D_s * (p * fluid_outward_normal[1]
- porosity*mu * (fluid_outward_normal[0] * (grad_u[1]+grad_v[0]) +
fluid_outward_normal[1] * 2* grad_v[1])
+C_surf*(v-v_s)*rho
);
force_p_x = dV * D_s * p * fluid_outward_normal[0];
force_p_y = dV * D_s * p * fluid_outward_normal[1];
force_stress_x = dV * D_s * (-porosity*mu * (fluid_outward_normal[0] * 2* grad_u[0] +
fluid_outward_normal[1] * (grad_u[1]+grad_v[0]))
+C_surf*(u-u_s)*rho
);
force_stress_y = dV * D_s * (-porosity*mu * (fluid_outward_normal[0] * (grad_u[1]+grad_v[0]) +
fluid_outward_normal[1] * 2* grad_v[1])
+C_surf*(v-v_s)*rho
);
//always 3D for particle centroids
r_x = x - center[0];
r_y = y - center[1];
if (element_owned)
{
particle_surfaceArea[i] += dV * D_s;
particle_netForces[i * 3 + 0] += force_x;
particle_netForces[i * 3 + 1] += force_y;
particle_netForces[(i+ nParticles)*3+0]+= force_p_x;
particle_netForces[(i+2*nParticles)*3+0]+= force_stress_x;
particle_netForces[(i+ nParticles)*3+1]+= force_p_y;
particle_netForces[(i+2*nParticles)*3+1]+= force_stress_y;
particle_netMoments[i * 3 + 2] += (r_x * force_y - r_y * force_x);
}
// These should be done inside to make sure the correct velocity of different particles are used
mom_u_source += C * (u - u_s);
mom_v_source += C * (v - v_s);
dmom_u_source[0] += C;
dmom_v_source[1] += C;
//Nitsche terms
mom_u_ham -= D_s * porosity * mu * (fluid_outward_normal[0] * grad_u[0] + fluid_outward_normal[1] * grad_u[1]);
dmom_u_ham_grad_u[0] -= D_s * porosity * mu * fluid_outward_normal[0];
dmom_u_ham_grad_u[1] -= D_s * porosity * mu * fluid_outward_normal[1];
mom_v_ham -= D_s * porosity * mu * (fluid_outward_normal[0] * grad_v[0] + fluid_outward_normal[1] * grad_v[1]);
dmom_v_ham_grad_v[0] -= D_s * porosity * mu * fluid_outward_normal[0];
dmom_v_ham_grad_v[1] -= D_s * porosity * mu * fluid_outward_normal[1];
mom_u_adv[0] += D_s * porosity * mu * fluid_outward_normal[0] * (u - u_s);
mom_u_adv[1] += D_s * porosity * mu * fluid_outward_normal[1] * (u - u_s);
dmom_u_adv_u[0] += D_s * porosity * mu * fluid_outward_normal[0];
dmom_u_adv_u[1] += D_s * porosity * mu * fluid_outward_normal[1];
mom_v_adv[0] += D_s * porosity * mu * fluid_outward_normal[0] * (v - v_s);
mom_v_adv[1] += D_s * porosity * mu * fluid_outward_normal[1] * (v - v_s);
dmom_v_adv_v[0] += D_s * porosity * mu * fluid_outward_normal[0];
dmom_v_adv_v[1] += D_s * porosity * mu * fluid_outward_normal[1];
}
}
inline void compute_force_around_solid(bool element_owned,
const double dV,
const int nParticles,
const int sd_offset,
double *particle_signed_distances,
double *particle_signed_distance_normals,
double *particle_velocities,
double *particle_centroids,
int use_ball_as_particle,
double* ball_center,
double* ball_radius,
double* ball_velocity,
double* ball_angular_velocity,
const double penalty,
const double alpha,
const double beta,
const double eps_rho,
const double eps_mu,
const double rho_0,
const double nu_0,
const double rho_1,
const double nu_1,
const double useVF,
const double vf,
const double phi,
const double x,
const double y,
const double z,
const double p,
const double u,
const double v,
const double w,
const double uStar,
const double vStar,
const double wStar,
const double eps_s,
const double grad_u[nSpace],
const double grad_v[nSpace],
const double grad_w[nSpace],
double* particle_netForces,
double* particle_netMoments)
{
double C, rho, mu, nu, H_mu, ImH_mu, uc, duc_du, duc_dv, duc_dw, H_s, D_s, phi_s, u_s, v_s, w_s, force_x, force_y, r_x, r_y;
double phi_s_normal[2];
double fluid_outward_normal[2];
double vel[2];
double center[2];
H_mu = (1.0 - useVF) * gf.H(eps_mu, phi) + useVF * fmin(1.0, fmax(0.0, vf));
ImH_mu = (1.0 - useVF) * gf.ImH(eps_mu, phi) + useVF * (1.0-fmin(1.0, fmax(0.0, vf)));
nu = nu_0 * ImH_mu + nu_1 * H_mu;
rho = rho_0 * ImH_mu + rho_1 * H_mu;
mu = rho_0 * nu_0 * ImH_mu + rho_1 * nu_1 * H_mu;
C = 0.0;
for (int i = 0; i < nParticles; i++)
{
if(use_ball_as_particle==1)
{
get_distance_to_ith_ball(nParticles,ball_center,ball_radius,i,x,y,z,phi_s);
get_normal_to_ith_ball(nParticles,ball_center,ball_radius,i,x,y,z,phi_s_normal[0],phi_s_normal[1]);
get_velocity_to_ith_ball(nParticles,ball_center,ball_radius,
ball_velocity,ball_angular_velocity,
i,x,y,z,
vel[0],vel[1]);
center[0] = ball_center[3*i+0];
center[1] = ball_center[3*i+1];
}
else
{
phi_s = particle_signed_distances[i * sd_offset];
phi_s_normal[0] = particle_signed_distance_normals[i * sd_offset * 3 + 0];
phi_s_normal[1] = particle_signed_distance_normals[i * sd_offset * 3 + 1];
vel[0] = particle_velocities[i * sd_offset * 3 + 0];
vel[1] = particle_velocities[i * sd_offset * 3 + 1];
center[0] = particle_centroids[3*i+0];
center[1] = particle_centroids[3*i+1];
}
fluid_outward_normal[0] = -phi_s_normal[0];
fluid_outward_normal[1] = -phi_s_normal[1];
u_s = vel[0];
v_s = vel[1];
w_s = 0;
H_s = gf_s.H(eps_s, phi_s);
D_s = gf_s.D(eps_s, phi_s);
double rel_vel_norm = sqrt((uStar - u_s) * (uStar - u_s) +(vStar - v_s) * (vStar - v_s) + (wStar - w_s) * (wStar - w_s));
double C_surf = (phi_s > 0.0) ? 0.0 : nu * penalty;
double C_vol = (phi_s > 0.0) ? 0.0 : (alpha + beta * rel_vel_norm);
C = (D_s * C_surf + gf_s.ImH(eps_s, phi_s) * C_vol);
force_x = dV * D_s * (p * fluid_outward_normal[0]
-mu * (fluid_outward_normal[0] * 2* grad_u[0] + fluid_outward_normal[1] * (grad_u[1]+grad_v[0]))
);
//+dV*D_s*C_surf*rel_vel_norm*(u-u_s)*rho
//+dV * (1.0 - H_s) * C_vol * (u - u_s) * rho;
force_y = dV * D_s * (p * fluid_outward_normal[1]
-mu * (fluid_outward_normal[0] * (grad_u[1]+grad_v[0]) + fluid_outward_normal[1] * 2* grad_v[1])
);
//+dV*D_s*C_surf*rel_vel_norm*(v-v_s)*rho
//+dV * (1.0 - H_s) * C_vol * (v - v_s) * rho;
//always 3D for particle centroids
r_x = x - center[0];
r_y = y - center[1];
if (element_owned)
{
particle_netForces[i * 3 + 0] += force_x;
particle_netForces[i * 3 + 1] += force_y;
particle_netMoments[i * 3 + 2] += (r_x * force_y - r_y * force_x);
}
}
}
inline
void calculateCFL(const double& hFactor,
const double& elementDiameter,
const double& dm,
const double df[nSpace],
double& cfl)
{
double h,density,nrm_df=0.0;
h = hFactor*elementDiameter;
density = dm;
for(int I=0;I<nSpace;I++)
nrm_df+=df[I]*df[I];
nrm_df = sqrt(nrm_df);
if (density > 1.0e-8)
cfl = nrm_df/(h*density);//this is really cfl/dt, but that's what we want to know, the step controller expect this
else
cfl = nrm_df/h;
//cfl = nrm_df/(h*density);//this is really cfl/dt, but that's what we want to know, the step controller expect this
}
inline void updateTurbulenceClosure(const int turbulenceClosureModel,
const double eps_rho,
const double eps_mu,
const double rho_0,
const double nu_0,
const double rho_1,
const double nu_1,
const double useVF,
const double vf,
const double phi,
const double porosity,
const double eddy_visc_coef_0,
const double turb_var_0, //k for k-eps or k-omega
const double turb_var_1, //epsilon for k-epsilon, omega for k-omega
const double turb_grad_0[nSpace], //grad k for k-eps,k-omega
double &eddy_viscosity,
double mom_uu_diff_ten[nSpace],
double mom_vv_diff_ten[nSpace],
double mom_ww_diff_ten[nSpace],
double mom_uv_diff_ten[1],
double mom_uw_diff_ten[1],
double mom_vu_diff_ten[1],
double mom_vw_diff_ten[1],
double mom_wu_diff_ten[1],
double mom_wv_diff_ten[1],
double &mom_u_source,
double &mom_v_source,
double &mom_w_source)
{
/****
eddy_visc_coef
<= 2 LES (do nothing)
== 3 k-epsilon
*/
assert (turbulenceClosureModel >=3);
double rho,nu,H_mu,ImH_mu,nu_t=0.0,nu_t_keps =0.0, nu_t_komega=0.0;
double isKEpsilon = 1.0;
if (turbulenceClosureModel == 4)
isKEpsilon = 0.0;
H_mu = (1.0-useVF)*gf.H(eps_mu,phi)+useVF*fmin(1.0,fmax(0.0,vf));
ImH_mu = (1.0-useVF)*gf.ImH(eps_mu,phi)+useVF*(1.0-fmin(1.0,fmax(0.0,vf)));
nu = nu_0*ImH_mu+nu_1*H_mu;
rho = rho_0*ImH_mu+rho_1*H_mu;
const double twoThirds = 2.0/3.0; const double div_zero = 1.0e-2*fmin(nu_0,nu_1);
mom_u_source += twoThirds*turb_grad_0[0];
mom_v_source += twoThirds*turb_grad_0[1];
/* mom_w_source += twoThirds*turb_grad_0[2]; */
//--- closure model specific ---
//k-epsilon
nu_t_keps = eddy_visc_coef_0*turb_var_0*turb_var_0/(fabs(turb_var_1) + div_zero);
//k-omega
nu_t_komega = turb_var_0/(fabs(turb_var_1) + div_zero);
//
nu_t = isKEpsilon*nu_t_keps + (1.0-isKEpsilon)*nu_t_komega;
//mwf debug
//if (nu_t > 1.e6*nu)
//{
// std::cout<<"RANS3PF2D WARNING isKEpsilon = "<<isKEpsilon<<" nu_t = " <<nu_t<<" nu= "<<nu<<" k= "<<turb_var_0<<" turb_var_1= "<<turb_var_1<<std::endl;
//}
nu_t = fmax(nu_t,1.0e-4*nu); //limit according to Lew, Buscaglia etal 01
//mwf hack
nu_t = fmin(nu_t,1.0e6*nu);
eddy_viscosity = nu_t*rho; // mql. CHECK.
//u momentum diffusion tensor
mom_uu_diff_ten[0] += porosity*2.0*eddy_viscosity;
mom_uu_diff_ten[1] += porosity*eddy_viscosity;
/* mom_uu_diff_ten[2] += porosity*eddy_viscosity; */
mom_uv_diff_ten[0]+=porosity*eddy_viscosity;
/* mom_uw_diff_ten[0]+=porosity*eddy_viscosity; */
//v momentum diffusion tensor
mom_vv_diff_ten[0] += porosity*eddy_viscosity;
mom_vv_diff_ten[1] += porosity*2.0*eddy_viscosity;
/* mom_vv_diff_ten[2] += porosity*eddy_viscosity; */
mom_vu_diff_ten[0]+=porosity*eddy_viscosity;
/* mom_vw_diff_ten[0]+=porosity*eddy_viscosity; */
/* //w momentum diffusion tensor */
/* mom_ww_diff_ten[0] += porosity*eddy_viscosity; */
/* mom_ww_diff_ten[1] += porosity*eddy_viscosity; */
/* mom_ww_diff_ten[2] += porosity*2.0*eddy_viscosity; */
/* mom_wu_diff_ten[0]+=porosity*eddy_viscosity; */
/* mom_wv_diff_ten[0]+=eddy_viscosity; */
}
inline void calculateSubgridError_tau(const double &hFactor,
const double &elementDiameter,
const double &dmt,
const double &dm,
const double df[nSpace],
const double &a,
const double &pfac,
double &tau_v,
double &tau_p,
double &cfl)
{
double h, oneByAbsdt, density, viscosity, nrm_df;
h = hFactor * elementDiameter;
density = dm;
viscosity = a;
nrm_df = 0.0;
for (int I = 0; I < nSpace; I++)
nrm_df += df[I] * df[I];
nrm_df = sqrt(nrm_df);
if (density > 1.0e-8)
cfl = nrm_df/(h*density);//this is really cfl/dt, but that's what we want to know, the step controller expect this
else
cfl = nrm_df/h;
oneByAbsdt = fabs(dmt);
tau_v = 1.0/(4.0*viscosity/(h*h) + 2.0*nrm_df/h + oneByAbsdt);
tau_p = (4.0*viscosity + 2.0*nrm_df*h + oneByAbsdt*h*h)/pfac;
}
inline void calculateSubgridError_tau(const double &Ct_sge,
const double &Cd_sge,
const double G[nSpace * nSpace],
const double &G_dd_G,
const double &tr_G,
const double &A0,
const double Ai[nSpace],
const double &Kij,
const double &pfac,
double &tau_v,
double &tau_p,
double &q_cfl)
{
double v_d_Gv = 0.0;
for (int I = 0; I < nSpace; I++)
for (int J = 0; J < nSpace; J++)
v_d_Gv += Ai[I] * G[I * nSpace + J] * Ai[J];
tau_v = 1.0 / sqrt(Ct_sge * A0 * A0 + v_d_Gv + Cd_sge * Kij * Kij * G_dd_G + 1.0e-12);
tau_p = 1.0 / (pfac * tr_G * tau_v);
}
inline void calculateSubgridError_tauRes(const double &tau_p,
const double &tau_v,
const double &pdeResidualP,
const double &pdeResidualU,
const double &pdeResidualV,
const double &pdeResidualW,
double &subgridErrorP,
double &subgridErrorU,
double &subgridErrorV,
double &subgridErrorW)
{
/* GLS pressure */
subgridErrorP = -tau_p * pdeResidualP;
/* GLS momentum */
subgridErrorU = -tau_v * pdeResidualU;
subgridErrorV = -tau_v * pdeResidualV;
/* subgridErrorW = -tau_v*pdeResidualW; */
}
inline void calculateSubgridErrorDerivatives_tauRes(const double &tau_p,
const double &tau_v,
const double dpdeResidualP_du[nDOF_trial_element],
const double dpdeResidualP_dv[nDOF_trial_element],
const double dpdeResidualP_dw[nDOF_trial_element],
const double dpdeResidualU_dp[nDOF_trial_element],
const double dpdeResidualU_du[nDOF_trial_element],
const double dpdeResidualV_dp[nDOF_trial_element],
const double dpdeResidualV_dv[nDOF_trial_element],
const double dpdeResidualW_dp[nDOF_trial_element],
const double dpdeResidualW_dw[nDOF_trial_element],
double dsubgridErrorP_du[nDOF_trial_element],
double dsubgridErrorP_dv[nDOF_trial_element],
double dsubgridErrorP_dw[nDOF_trial_element],
double dsubgridErrorU_dp[nDOF_trial_element],
double dsubgridErrorU_du[nDOF_trial_element],
double dsubgridErrorV_dp[nDOF_trial_element],
double dsubgridErrorV_dv[nDOF_trial_element],
double dsubgridErrorW_dp[nDOF_trial_element],
double dsubgridErrorW_dw[nDOF_trial_element])
{
for (int j = 0; j < nDOF_trial_element; j++)
{
/* GLS pressure */
dsubgridErrorP_du[j] = -tau_p * dpdeResidualP_du[j];
dsubgridErrorP_dv[j] = -tau_p * dpdeResidualP_dv[j];
/* dsubgridErrorP_dw[j] = -tau_p*dpdeResidualP_dw[j]; */
/* GLS momentum*/
/* u */
dsubgridErrorU_dp[j] = -tau_v * dpdeResidualU_dp[j];
dsubgridErrorU_du[j] = -tau_v * dpdeResidualU_du[j];
/* v */
dsubgridErrorV_dp[j] = -tau_v * dpdeResidualV_dp[j];
dsubgridErrorV_dv[j] = -tau_v * dpdeResidualV_dv[j];
/* /\* w *\/ */
/* dsubgridErrorW_dp[j] = -tau_v*dpdeResidualW_dp[j]; */
/* dsubgridErrorW_dw[j] = -tau_v*dpdeResidualW_dw[j]; */
}
}
inline
void exteriorNumericalAdvectiveFlux(const int& isDOFBoundary_p,
const int& isDOFBoundary_u,
const int& isDOFBoundary_v,
const int& isDOFBoundary_w,
const int& isFluxBoundary_p,
const int& isFluxBoundary_u,
const int& isFluxBoundary_v,
const int& isFluxBoundary_w,
const double& oneByRho,
const double& bc_oneByRho,
const double n[nSpace],
const double& porosity,
const double& bc_p,
const double& bc_u,
const double& bc_v,
const double& bc_w,
const double bc_f_mass[nSpace],
const double bc_f_umom[nSpace],
const double bc_f_vmom[nSpace],
const double bc_f_wmom[nSpace],
const double& bc_flux_mass,
const double& bc_flux_umom,
const double& bc_flux_vmom,
const double& bc_flux_wmom,
const double& p,
const double& u,
const double& v,
const double& w,
const double f_mass[nSpace],
const double f_umom[nSpace],
const double f_vmom[nSpace],
const double f_wmom[nSpace],
const double df_mass_du[nSpace],
const double df_mass_dv[nSpace],
const double df_mass_dw[nSpace],
const double df_umom_dp[nSpace],
const double df_umom_du[nSpace],
const double df_umom_dv[nSpace],
const double df_umom_dw[nSpace],
const double df_vmom_dp[nSpace],
const double df_vmom_du[nSpace],
const double df_vmom_dv[nSpace],
const double df_vmom_dw[nSpace],
const double df_wmom_dp[nSpace],
const double df_wmom_du[nSpace],
const double df_wmom_dv[nSpace],
const double df_wmom_dw[nSpace],
double& flux_mass,
double& flux_umom,
double& flux_vmom,
double& flux_wmom,
double* velocity_star,
double* velocity)
{
double flowSpeedNormal;
flux_mass = 0.0;
flux_umom = 0.0;
flux_vmom = 0.0;
/* flux_wmom = 0.0; */
flowSpeedNormal=porosity*(n[0]*velocity_star[0] +
n[1]*velocity_star[1]);
velocity[0] = u;
velocity[1] = v;
/* velocity[2] = w; */
if (isDOFBoundary_u != 1)
{
flux_mass += n[0]*f_mass[0];
if (flowSpeedNormal < 0.0)
{
flux_umom+=flowSpeedNormal*(0.0 - u);
}
}
else
{
flux_mass += n[0]*f_mass[0];
if (flowSpeedNormal < 0.0)
{
flux_umom+=flowSpeedNormal*(bc_u - u);
velocity[0] = bc_u;
}
}
if (isDOFBoundary_v != 1)
{
flux_mass+=n[1]*f_mass[1];
if (flowSpeedNormal < 0.0)
{
flux_vmom+=flowSpeedNormal*(0.0 - v);
}
}
else
{
flux_mass+=n[1]*f_mass[1];
if (flowSpeedNormal < 0.0)
{
flux_vmom+=flowSpeedNormal*(bc_v - v);
velocity[1] = bc_v;
}
}
/* if (isDOFBoundary_w != 1) */
/* { */
/* flux_mass+=n[2]*f_mass[2]; */
/* } */
/* else */
/* { */
/* flux_mass +=n[2]*f_mass[2]; */
/* if (flowSpeedNormal < 0.0) */
/* { */
/* flux_wmom+=flowSpeedNormal*(bc_w - w); */
/* } */
/* } */
/* if (isDOFBoundary_w != 1) */
/* { */
/* flux_mass+=n[2]*f_mass[2]; */
/* } */
/* else */
/* { */
/* flux_mass +=n[2]*f_mass[2]; */
/* if (flowSpeedNormal < 0.0) */
/* flux_wmom+=bc_speed*(bc_w - w); */
/* } */
if (isFluxBoundary_u == 1)
{
flux_umom = bc_flux_umom;
velocity[0] = bc_flux_umom/porosity;
}
if (isFluxBoundary_v == 1)
{
flux_vmom = bc_flux_vmom;
velocity[1] = bc_flux_umom/porosity;
}
/* if (isFluxBoundary_w == 1) */
/* { */
/* flux_wmom = bc_flux_wmom; */
/* } */
}
inline
void exteriorNumericalAdvectiveFluxDerivatives(const int& isDOFBoundary_p,
const int& isDOFBoundary_u,
const int& isDOFBoundary_v,
const int& isDOFBoundary_w,
const int& isFluxBoundary_p,
const int& isFluxBoundary_u,
const int& isFluxBoundary_v,
const int& isFluxBoundary_w,
const double& oneByRho,
const double n[nSpace],
const double& porosity, //mql. CHECK. Multiply by rho outside
const double& bc_p,
const double& bc_u,
const double& bc_v,
const double& bc_w,
const double bc_f_mass[nSpace],
const double bc_f_umom[nSpace],
const double bc_f_vmom[nSpace],
const double bc_f_wmom[nSpace],
const double& bc_flux_mass,
const double& bc_flux_umom,
const double& bc_flux_vmom,
const double& bc_flux_wmom,
const double& p,
const double& u,
const double& v,
const double& w,
const double f_mass[nSpace],
const double f_umom[nSpace],
const double f_vmom[nSpace],
const double f_wmom[nSpace],
const double df_mass_du[nSpace],
const double df_mass_dv[nSpace],
const double df_mass_dw[nSpace],
const double df_umom_dp[nSpace],
const double df_umom_du[nSpace],
const double df_umom_dv[nSpace],
const double df_umom_dw[nSpace],
const double df_vmom_dp[nSpace],
const double df_vmom_du[nSpace],
const double df_vmom_dv[nSpace],
const double df_vmom_dw[nSpace],
const double df_wmom_dp[nSpace],
const double df_wmom_du[nSpace],
const double df_wmom_dv[nSpace],
const double df_wmom_dw[nSpace],
double& dflux_mass_du,
double& dflux_mass_dv,
double& dflux_mass_dw,
double& dflux_umom_dp,
double& dflux_umom_du,
double& dflux_umom_dv,
double& dflux_umom_dw,
double& dflux_vmom_dp,
double& dflux_vmom_du,
double& dflux_vmom_dv,
double& dflux_vmom_dw,
double& dflux_wmom_dp,
double& dflux_wmom_du,
double& dflux_wmom_dv,
double& dflux_wmom_dw,
double* velocity_star)
{
double flowSpeedNormal;
dflux_mass_du = 0.0;
dflux_mass_dv = 0.0;
/* dflux_mass_dw = 0.0; */
dflux_umom_dp = 0.0;
dflux_umom_du = 0.0;
dflux_umom_dv = 0.0;
/* dflux_umom_dw = 0.0; */
dflux_vmom_dp = 0.0;
dflux_vmom_du = 0.0;
dflux_vmom_dv = 0.0;
/* dflux_vmom_dw = 0.0; */
dflux_wmom_dp = 0.0;
dflux_wmom_du = 0.0;
dflux_wmom_dv = 0.0;
/* dflux_wmom_dw = 0.0; */
flowSpeedNormal=porosity*(n[0]*velocity_star[0] +
n[1]*velocity_star[1]);
if (isDOFBoundary_u != 1)
{
dflux_mass_du += n[0]*df_mass_du[0];
if (flowSpeedNormal < 0.0)
dflux_umom_du -= flowSpeedNormal;
}
else
{
dflux_mass_du += n[0]*df_mass_du[0];
if (flowSpeedNormal < 0.0)
dflux_umom_du -= flowSpeedNormal;
}
if (isDOFBoundary_v != 1)
{
dflux_mass_dv += n[1]*df_mass_dv[1];
if (flowSpeedNormal < 0.0)
dflux_vmom_dv -= flowSpeedNormal;
}
else
{
dflux_mass_dv += n[1]*df_mass_dv[1];
if (flowSpeedNormal < 0.0)
dflux_vmom_dv -= flowSpeedNormal;
}
/* if (isDOFBoundary_w != 1) */
/* { */
/* dflux_mass_dw+=n[2]*df_mass_dw[2]; */
/* } */
/* else */
/* { */
/* dflux_mass_dw += n[2]*df_mass_dw[2]; */
/* if (flowSpeedNormal < 0.0) */
/* dflux_wmom_dw -= flowSpeedNormal; */
/* } */
/* if (isDOFBoundary_w != 1) */
/* { */
/* dflux_mass_dw+=n[2]*df_mass_dw[2]; */
/* } */
/* else */
/* { */
/* dflux_mass_dw += n[2]*df_mass_dw[2]; */
/* if (flowSpeedNormal < 0.0) */
/* dflux_wmom_dw += bc_speed; */
/* } */
/* if (isDOFBoundary_p == 1) */
/* { */
/* dflux_umom_dp= -n[0]*oneByRho; */
/* dflux_vmom_dp= -n[1]*oneByRho; */
/* /\* dflux_wmom_dp= -n[2]*oneByRho; *\/ */
/* } */
/* if (isFluxBoundary_p == 1) */
/* { */
/* dflux_mass_du = 0.0; */
/* dflux_mass_dv = 0.0; */
/* /\* dflux_mass_dw = 0.0; *\/ */
/* } */
if (isFluxBoundary_u == 1)
{
dflux_umom_dp = 0.0;
dflux_umom_du = 0.0;
dflux_umom_dv = 0.0;
/* dflux_umom_dw = 0.0; */
}
if (isFluxBoundary_v == 1)
{
dflux_vmom_dp = 0.0;
dflux_vmom_du = 0.0;
dflux_vmom_dv = 0.0;
/* dflux_vmom_dw = 0.0; */
}
/* if (isFluxBoundary_w == 1) */
/* { */
/* dflux_wmom_dp = 0.0; */
/* dflux_wmom_du = 0.0; */
/* dflux_wmom_dv = 0.0; */
/* dflux_wmom_dw = 0.0; */
/* } */
}
inline
void exteriorNumericalDiffusiveFlux(const double& eps,
const double& phi,
int* rowptr,
int* colind,
const int& isDOFBoundary,
const int& isFluxBoundary,
const double n[nSpace],
double* bc_a,
const double& bc_u,
const double& bc_flux,
double* a,
const double grad_potential[nSpace],
const double& u,
const double& penalty,
double& flux)
{
double diffusiveVelocityComponent_I,penaltyFlux,max_a;
if(isFluxBoundary == 1)
{
flux = bc_flux;
}
else if(isDOFBoundary == 1)
{
flux = 0.0;
max_a=0.0;
for(int I=0;I<nSpace;I++)
{
diffusiveVelocityComponent_I=0.0;
for(int m=rowptr[I];m<rowptr[I+1];m++)
{
diffusiveVelocityComponent_I -= a[m]*grad_potential[colind[m]];
max_a = fmax(max_a,a[m]);
}
flux+= diffusiveVelocityComponent_I*n[I];
}
penaltyFlux = max_a*penalty*(u-bc_u);
flux += penaltyFlux;
//contact line slip
//flux*=(gf.D(eps,0) - gf.D(eps,phi))/gf.D(eps,0);
}
else
{
std::cerr<<"RANS3PF2D: warning, diffusion term with no boundary condition set, setting diffusive flux to 0.0"<<std::endl;
flux = 0.0;
}
}
inline
double ExteriorNumericalDiffusiveFluxJacobian(const double& eps,
const double& phi,
int* rowptr,
int* colind,
const int& isDOFBoundary,
const int& isFluxBoundary,
const double n[nSpace],
double* a,
const double& v,
const double grad_v[nSpace],
const double& penalty)
{
double dvel_I,tmp=0.0,max_a=0.0;
if(isFluxBoundary==0 && isDOFBoundary==1)
{
for(int I=0;I<nSpace;I++)
{
dvel_I=0.0;
for(int m=rowptr[I];m<rowptr[I+1];m++)
{
dvel_I -= a[m]*grad_v[colind[m]];
max_a = fmax(max_a,a[m]);
}
tmp += dvel_I*n[I];
}
tmp +=max_a*penalty*v;
//contact line slip
//tmp*=(gf.D(eps,0) - gf.D(eps,phi))/gf.D(eps,0);
}
return tmp;
}
void get_symmetric_gradient_dot_vec(const double *grad_u, const double *grad_v, const double *n,double res[2])
{
// res[0] = 2.0*grad_u[0]*n[0]+(grad_u[1]+grad_v[0])*n[1];
// res[1] = (grad_v[0]+grad_u[1])*n[0]+ 2*grad_v[1]*n[1];
res[0] = grad_u[0]*n[0]+grad_u[1]*n[1];
res[1] = grad_v[0]*n[0]+grad_v[1]*n[1];
}
double get_cross_product(const double *u, const double *v)
{
return u[0]*v[1]-u[1]*v[0];
}
double get_dot_product(const double *u, const double *v)
{
return u[0]*v[0]+u[1]*v[1];
}
int get_distance_to_ball(int n_balls,double* ball_center, double* ball_radius, double x, double y, double z, double& distance)
{
distance = 1e10;
int index = -1;
double d_ball_i;
for (int i=0; i<n_balls; ++i)
{
d_ball_i = std::sqrt((ball_center[i*3+0]-x)*(ball_center[i*3+0]-x)
+(ball_center[i*3+1]-y)*(ball_center[i*3+1]-y)
// +(ball_center[i*3+2]-z)*(ball_center[i*3+2]-z)
) - ball_radius[i];
if(d_ball_i<distance)
{
distance = d_ball_i;
index = i;
}
}
return index;
}
void get_distance_to_ith_ball(int n_balls,double* ball_center, double* ball_radius,
int I,
double x, double y, double z,
double& distance)
{
distance = std::sqrt((ball_center[I*3+0]-x)*(ball_center[I*3+0]-x)
+ (ball_center[I*3+1]-y)*(ball_center[I*3+1]-y)
// + (ball_center[I*3+2]-z)*(ball_center[I*3+2]-z)
) - ball_radius[I];
}
void get_normal_to_ith_ball(int n_balls,double* ball_center, double* ball_radius,
int I,
double x, double y, double z,
double& nx, double& ny)
{
double distance = std::sqrt((ball_center[I*3+0]-x)*(ball_center[I*3+0]-x)
+ (ball_center[I*3+1]-y)*(ball_center[I*3+1]-y)
// + (ball_center[I*3+2]-z)*(ball_center[I*3+2]-z)
);
nx = (x - ball_center[I*3+0])/(distance+1e-10);
ny = (y - ball_center[I*3+1])/(distance+1e-10);
}
void get_velocity_to_ith_ball(int n_balls,double* ball_center, double* ball_radius,
double* ball_velocity, double* ball_angular_velocity,
int I,
double x, double y, double z,
double& vx, double& vy)
{
vx = ball_velocity[3*I + 0] - ball_angular_velocity[3*I + 2]*(y-ball_center[3*I + 1]);
vy = ball_velocity[3*I + 1] + ball_angular_velocity[3*I + 2]*(x-ball_center[3*I + 0]);
}
void calculateResidual(arguments_dict& args,
bool useExact)
{
xt::pyarray<double>& mesh_trial_ref = args.m_darray["mesh_trial_ref"];
xt::pyarray<double>& mesh_grad_trial_ref = args.m_darray["mesh_grad_trial_ref"];
xt::pyarray<double>& mesh_dof = args.m_darray["mesh_dof"];
xt::pyarray<double>& mesh_velocity_dof = args.m_darray["mesh_velocity_dof"];
double MOVING_DOMAIN = args.m_dscalar["MOVING_DOMAIN"];
double PSTAB = args.m_dscalar["PSTAB"];
xt::pyarray<int>& mesh_l2g = args.m_iarray["mesh_l2g"];
xt::pyarray<double>& x_ref = args.m_darray["x_ref"];
xt::pyarray<double>& dV_ref = args.m_darray["dV_ref"];
int nDOF_per_element_pressure = args.m_iscalar["nDOF_per_element_pressure"];
xt::pyarray<double>& p_trial_ref = args.m_darray["p_trial_ref"];
xt::pyarray<double>& p_grad_trial_ref = args.m_darray["p_grad_trial_ref"];
xt::pyarray<double>& p_test_ref = args.m_darray["p_test_ref"];
xt::pyarray<double>& p_grad_test_ref = args.m_darray["p_grad_test_ref"];
xt::pyarray<double>& q_p = args.m_darray["q_p"];
xt::pyarray<double>& q_grad_p = args.m_darray["q_grad_p"];
xt::pyarray<double>& ebqe_p = args.m_darray["ebqe_p"];
xt::pyarray<double>& ebqe_grad_p = args.m_darray["ebqe_grad_p"];
xt::pyarray<double>& vel_trial_ref = args.m_darray["vel_trial_ref"];
xt::pyarray<double>& vel_grad_trial_ref = args.m_darray["vel_grad_trial_ref"];
xt::pyarray<double>& vel_hess_trial_ref = args.m_darray["vel_hess_trial_ref"];
xt::pyarray<double>& vel_test_ref = args.m_darray["vel_test_ref"];
xt::pyarray<double>& vel_grad_test_ref = args.m_darray["vel_grad_test_ref"];
xt::pyarray<double>& mesh_trial_trace_ref = args.m_darray["mesh_trial_trace_ref"];
xt::pyarray<double>& mesh_grad_trial_trace_ref = args.m_darray["mesh_grad_trial_trace_ref"];
xt::pyarray<double>& dS_ref = args.m_darray["dS_ref"];
xt::pyarray<double>& p_trial_trace_ref = args.m_darray["p_trial_trace_ref"];
xt::pyarray<double>& p_grad_trial_trace_ref = args.m_darray["p_grad_trial_trace_ref"];
xt::pyarray<double>& p_test_trace_ref = args.m_darray["p_test_trace_ref"];
xt::pyarray<double>& p_grad_test_trace_ref = args.m_darray["p_grad_test_trace_ref"];
xt::pyarray<double>& vel_trial_trace_ref = args.m_darray["vel_trial_trace_ref"];
xt::pyarray<double>& vel_grad_trial_trace_ref = args.m_darray["vel_grad_trial_trace_ref"];
xt::pyarray<double>& vel_test_trace_ref = args.m_darray["vel_test_trace_ref"];
xt::pyarray<double>& vel_grad_test_trace_ref = args.m_darray["vel_grad_test_trace_ref"];
xt::pyarray<double>& normal_ref = args.m_darray["normal_ref"];
xt::pyarray<double>& boundaryJac_ref = args.m_darray["boundaryJac_ref"];
double eb_adjoint_sigma = args.m_dscalar["eb_adjoint_sigma"];
xt::pyarray<double>& elementDiameter = args.m_darray["elementDiameter"];
xt::pyarray<double>& nodeDiametersArray = args.m_darray["nodeDiametersArray"];
double hFactor = args.m_dscalar["hFactor"];
int nElements_global = args.m_iscalar["nElements_global"];
int nElements_owned = args.m_iscalar["nElements_owned"];
int nElementBoundaries_global = args.m_iscalar["nElementBoundaries_global"];
int nElementBoundaries_owned = args.m_iscalar["nElementBoundaries_owned"];
int nNodes_owned = args.m_iscalar["nNodes_owned"];
double useRBLES = args.m_dscalar["useRBLES"];
double useMetrics = args.m_dscalar["useMetrics"];
double alphaBDF = args.m_dscalar["alphaBDF"];
double epsFact_rho = args.m_dscalar["epsFact_rho"];
double epsFact_mu = args.m_dscalar["epsFact_mu"];
double sigma = args.m_dscalar["sigma"];
double rho_0 = args.m_dscalar["rho_0"];
double nu_0 = args.m_dscalar["nu_0"];
double rho_1 = args.m_dscalar["rho_1"];
double nu_1 = args.m_dscalar["nu_1"];
double smagorinskyConstant = args.m_dscalar["smagorinskyConstant"];
int turbulenceClosureModel = args.m_iscalar["turbulenceClosureModel"];
double Ct_sge = args.m_dscalar["Ct_sge"];
double Cd_sge = args.m_dscalar["Cd_sge"];
double C_dc = args.m_dscalar["C_dc"];
double C_b = args.m_dscalar["C_b"];
const xt::pyarray<double>& eps_solid = args.m_darray["eps_solid"];
const xt::pyarray<double>& ebq_global_phi_solid = args.m_darray["ebq_global_phi_solid"];
const xt::pyarray<double>& ebq_global_grad_phi_solid = args.m_darray["ebq_global_grad_phi_solid"];
const xt::pyarray<double>& ebq_particle_velocity_solid = args.m_darray["ebq_particle_velocity_solid"];
xt::pyarray<double>& phi_solid_nodes = args.m_darray["phi_solid_nodes"];
xt::pyarray<double>& phi_solid = args.m_darray["phi_solid"];
const xt::pyarray<double>& q_velocity_solid = args.m_darray["q_velocity_solid"];
const xt::pyarray<double>& q_velocityStar_solid = args.m_darray["q_velocityStar_solid"];
const xt::pyarray<double>& q_vos = args.m_darray["q_vos"];
const xt::pyarray<double>& q_dvos_dt = args.m_darray["q_dvos_dt"];
const xt::pyarray<double>& q_grad_vos = args.m_darray["q_grad_vos"];
const xt::pyarray<double>& q_dragAlpha = args.m_darray["q_dragAlpha"];
const xt::pyarray<double>& q_dragBeta = args.m_darray["q_dragBeta"];
const xt::pyarray<double>& q_mass_source = args.m_darray["q_mass_source"];
const xt::pyarray<double>& q_turb_var_0 = args.m_darray["q_turb_var_0"];
const xt::pyarray<double>& q_turb_var_1 = args.m_darray["q_turb_var_1"];
const xt::pyarray<double>& q_turb_var_grad_0 = args.m_darray["q_turb_var_grad_0"];
xt::pyarray<double>& q_eddy_viscosity = args.m_darray["q_eddy_viscosity"];
xt::pyarray<int>& p_l2g = args.m_iarray["p_l2g"];
xt::pyarray<int>& vel_l2g = args.m_iarray["vel_l2g"];
xt::pyarray<double>& p_dof = args.m_darray["p_dof"];
xt::pyarray<double>& u_dof = args.m_darray["u_dof"];
xt::pyarray<double>& v_dof = args.m_darray["v_dof"];
xt::pyarray<double>& w_dof = args.m_darray["w_dof"];
xt::pyarray<double>& u_dof_old = args.m_darray["u_dof_old"];
xt::pyarray<double>& v_dof_old = args.m_darray["v_dof_old"];
xt::pyarray<double>& w_dof_old = args.m_darray["w_dof_old"];
xt::pyarray<double>& u_dof_old_old = args.m_darray["u_dof_old_old"];
xt::pyarray<double>& v_dof_old_old = args.m_darray["v_dof_old_old"];
xt::pyarray<double>& w_dof_old_old = args.m_darray["w_dof_old_old"];
xt::pyarray<double>& uStar_dof = args.m_darray["uStar_dof"];
xt::pyarray<double>& vStar_dof = args.m_darray["vStar_dof"];
xt::pyarray<double>& wStar_dof = args.m_darray["wStar_dof"];
xt::pyarray<double>& g = args.m_darray["g"];
const double useVF = args.m_dscalar["useVF"];
xt::pyarray<double>& vf = args.m_darray["vf"];
xt::pyarray<double>& phi = args.m_darray["phi"];
xt::pyarray<double>& phi_dof = args.m_darray["phi_dof"];
xt::pyarray<double>& normal_phi = args.m_darray["normal_phi"];
xt::pyarray<double>& kappa_phi = args.m_darray["kappa_phi"];
xt::pyarray<double>& q_mom_u_acc = args.m_darray["q_mom_u_acc"];
xt::pyarray<double>& q_mom_v_acc = args.m_darray["q_mom_v_acc"];
xt::pyarray<double>& q_mom_w_acc = args.m_darray["q_mom_w_acc"];
xt::pyarray<double>& q_mass_adv = args.m_darray["q_mass_adv"];
xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.m_darray["q_mom_u_acc_beta_bdf"];
xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.m_darray["q_mom_v_acc_beta_bdf"];
xt::pyarray<double>& q_mom_w_acc_beta_bdf = args.m_darray["q_mom_w_acc_beta_bdf"];
xt::pyarray<double>& q_dV = args.m_darray["q_dV"];
xt::pyarray<double>& q_dV_last = args.m_darray["q_dV_last"];
xt::pyarray<double>& q_velocity_sge = args.m_darray["q_velocity_sge"];
xt::pyarray<double>& ebqe_velocity_star = args.m_darray["ebqe_velocity_star"];
xt::pyarray<double>& q_cfl = args.m_darray["q_cfl"];
xt::pyarray<double>& q_numDiff_u = args.m_darray["q_numDiff_u"];
xt::pyarray<double>& q_numDiff_v = args.m_darray["q_numDiff_v"];
xt::pyarray<double>& q_numDiff_w = args.m_darray["q_numDiff_w"];
xt::pyarray<double>& q_numDiff_u_last = args.m_darray["q_numDiff_u_last"];
xt::pyarray<double>& q_numDiff_v_last = args.m_darray["q_numDiff_v_last"];
xt::pyarray<double>& q_numDiff_w_last = args.m_darray["q_numDiff_w_last"];
xt::pyarray<int>& sdInfo_u_u_rowptr = args.m_iarray["sdInfo_u_u_rowptr"];
xt::pyarray<int>& sdInfo_u_u_colind = args.m_iarray["sdInfo_u_u_colind"];
xt::pyarray<int>& sdInfo_u_v_rowptr = args.m_iarray["sdInfo_u_v_rowptr"];
xt::pyarray<int>& sdInfo_u_v_colind = args.m_iarray["sdInfo_u_v_colind"];
xt::pyarray<int>& sdInfo_u_w_rowptr = args.m_iarray["sdInfo_u_w_rowptr"];
xt::pyarray<int>& sdInfo_u_w_colind = args.m_iarray["sdInfo_u_w_colind"];
xt::pyarray<int>& sdInfo_v_v_rowptr = args.m_iarray["sdInfo_v_v_rowptr"];
xt::pyarray<int>& sdInfo_v_v_colind = args.m_iarray["sdInfo_v_v_colind"];
xt::pyarray<int>& sdInfo_v_u_rowptr = args.m_iarray["sdInfo_v_u_rowptr"];
xt::pyarray<int>& sdInfo_v_u_colind = args.m_iarray["sdInfo_v_u_colind"];
xt::pyarray<int>& sdInfo_v_w_rowptr = args.m_iarray["sdInfo_v_w_rowptr"];
xt::pyarray<int>& sdInfo_v_w_colind = args.m_iarray["sdInfo_v_w_colind"];
xt::pyarray<int>& sdInfo_w_w_rowptr = args.m_iarray["sdInfo_w_w_rowptr"];
xt::pyarray<int>& sdInfo_w_w_colind = args.m_iarray["sdInfo_w_w_colind"];
xt::pyarray<int>& sdInfo_w_u_rowptr = args.m_iarray["sdInfo_w_u_rowptr"];
xt::pyarray<int>& sdInfo_w_u_colind = args.m_iarray["sdInfo_w_u_colind"];
xt::pyarray<int>& sdInfo_w_v_rowptr = args.m_iarray["sdInfo_w_v_rowptr"];
xt::pyarray<int>& sdInfo_w_v_colind = args.m_iarray["sdInfo_w_v_colind"];
int offset_p = args.m_iscalar["offset_p"];
int offset_u = args.m_iscalar["offset_u"];
int offset_v = args.m_iscalar["offset_v"];
int offset_w = args.m_iscalar["offset_w"];
int stride_p = args.m_iscalar["stride_p"];
int stride_u = args.m_iscalar["stride_u"];
int stride_v = args.m_iscalar["stride_v"];
int stride_w = args.m_iscalar["stride_w"];
xt::pyarray<double>& globalResidual = args.m_darray["globalResidual"];
int nExteriorElementBoundaries_global = args.m_iscalar["nExteriorElementBoundaries_global"];
xt::pyarray<int>& exteriorElementBoundariesArray = args.m_iarray["exteriorElementBoundariesArray"];
xt::pyarray<int>& elementBoundariesArray = args.m_iarray["elementBoundariesArray"];
xt::pyarray<int>& elementBoundaryElementsArray = args.m_iarray["elementBoundaryElementsArray"];
xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.m_iarray["elementBoundaryLocalElementBoundariesArray"];
xt::pyarray<double>& ebqe_vf_ext = args.m_darray["ebqe_vf_ext"];
xt::pyarray<double>& bc_ebqe_vf_ext = args.m_darray["bc_ebqe_vf_ext"];
xt::pyarray<double>& ebqe_phi_ext = args.m_darray["ebqe_phi_ext"];
xt::pyarray<double>& bc_ebqe_phi_ext = args.m_darray["bc_ebqe_phi_ext"];
xt::pyarray<double>& ebqe_normal_phi_ext = args.m_darray["ebqe_normal_phi_ext"];
xt::pyarray<double>& ebqe_kappa_phi_ext = args.m_darray["ebqe_kappa_phi_ext"];
const xt::pyarray<double>& ebqe_vos_ext = args.m_darray["ebqe_vos_ext"];
const xt::pyarray<double>& ebqe_turb_var_0 = args.m_darray["ebqe_turb_var_0"];
const xt::pyarray<double>& ebqe_turb_var_1 = args.m_darray["ebqe_turb_var_1"];
xt::pyarray<int>& isDOFBoundary_p = args.m_iarray["isDOFBoundary_p"];
xt::pyarray<int>& isDOFBoundary_u = args.m_iarray["isDOFBoundary_u"];
xt::pyarray<int>& isDOFBoundary_v = args.m_iarray["isDOFBoundary_v"];
xt::pyarray<int>& isDOFBoundary_w = args.m_iarray["isDOFBoundary_w"];
xt::pyarray<int>& isAdvectiveFluxBoundary_p = args.m_iarray["isAdvectiveFluxBoundary_p"];
xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.m_iarray["isAdvectiveFluxBoundary_u"];
xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.m_iarray["isAdvectiveFluxBoundary_v"];
xt::pyarray<int>& isAdvectiveFluxBoundary_w = args.m_iarray["isAdvectiveFluxBoundary_w"];
xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.m_iarray["isDiffusiveFluxBoundary_u"];
xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.m_iarray["isDiffusiveFluxBoundary_v"];
xt::pyarray<int>& isDiffusiveFluxBoundary_w = args.m_iarray["isDiffusiveFluxBoundary_w"];
xt::pyarray<double>& ebqe_bc_p_ext = args.m_darray["ebqe_bc_p_ext"];
xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.m_darray["ebqe_bc_flux_mass_ext"];
xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.m_darray["ebqe_bc_flux_mom_u_adv_ext"];
xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.m_darray["ebqe_bc_flux_mom_v_adv_ext"];
xt::pyarray<double>& ebqe_bc_flux_mom_w_adv_ext = args.m_darray["ebqe_bc_flux_mom_w_adv_ext"];
xt::pyarray<double>& ebqe_bc_u_ext = args.m_darray["ebqe_bc_u_ext"];
xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.m_darray["ebqe_bc_flux_u_diff_ext"];
xt::pyarray<double>& ebqe_penalty_ext = args.m_darray["ebqe_penalty_ext"];
xt::pyarray<double>& ebqe_bc_v_ext = args.m_darray["ebqe_bc_v_ext"];
xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.m_darray["ebqe_bc_flux_v_diff_ext"];
xt::pyarray<double>& ebqe_bc_w_ext = args.m_darray["ebqe_bc_w_ext"];
xt::pyarray<double>& ebqe_bc_flux_w_diff_ext = args.m_darray["ebqe_bc_flux_w_diff_ext"];
xt::pyarray<double>& q_x = args.m_darray["q_x"];
xt::pyarray<double>& q_velocity = args.m_darray["q_velocity"];
xt::pyarray<double>& ebqe_velocity = args.m_darray["ebqe_velocity"];
xt::pyarray<double>& q_grad_u = args.m_darray["q_grad_u"];
xt::pyarray<double>& q_grad_v = args.m_darray["q_grad_v"];
xt::pyarray<double>& q_grad_w = args.m_darray["q_grad_w"];
xt::pyarray<double>& q_divU = args.m_darray["q_divU"];
xt::pyarray<double>& ebqe_grad_u = args.m_darray["ebqe_grad_u"];
xt::pyarray<double>& ebqe_grad_v = args.m_darray["ebqe_grad_v"];
xt::pyarray<double>& ebqe_grad_w = args.m_darray["ebqe_grad_w"];
xt::pyarray<double>& flux = args.m_darray["flux"];
xt::pyarray<double>& elementResidual_p_save = args.m_darray["elementResidual_p_save"];
xt::pyarray<int>& elementFlags = args.m_iarray["elementFlags"];
xt::pyarray<int>& boundaryFlags = args.m_iarray["boundaryFlags"];
xt::pyarray<double>& barycenters = args.m_darray["barycenters"];
xt::pyarray<double>& wettedAreas = args.m_darray["wettedAreas"];
xt::pyarray<double>& netForces_p = args.m_darray["netForces_p"];
xt::pyarray<double>& netForces_v = args.m_darray["netForces_v"];
xt::pyarray<double>& netMoments = args.m_darray["netMoments"];
xt::pyarray<double>& q_rho = args.m_darray["q_rho"];
xt::pyarray<double>& ebqe_rho = args.m_darray["ebqe_rho"];
xt::pyarray<double>& q_nu = args.m_darray["q_nu"];
xt::pyarray<double>& ebqe_nu = args.m_darray["ebqe_nu"];
int nParticles = args.m_iscalar["nParticles"];
double particle_epsFact = args.m_dscalar["particle_epsFact"];
double particle_alpha = args.m_dscalar["particle_alpha"];
double particle_beta = args.m_dscalar["particle_beta"];
double particle_penalty_constant = args.m_dscalar["particle_penalty_constant"];
xt::pyarray<double>& particle_signed_distances = args.m_darray["particle_signed_distances"];
xt::pyarray<double>& particle_signed_distance_normals = args.m_darray["particle_signed_distance_normals"];
xt::pyarray<double>& particle_velocities = args.m_darray["particle_velocities"];
xt::pyarray<double>& particle_centroids = args.m_darray["particle_centroids"];
xt::pyarray<double>& particle_netForces = args.m_darray["particle_netForces"];
xt::pyarray<double>& particle_netMoments = args.m_darray["particle_netMoments"];
xt::pyarray<double>& particle_surfaceArea = args.m_darray["particle_surfaceArea"];
double particle_nitsche = args.m_dscalar["particle_nitsche"];
int use_ball_as_particle = args.m_iscalar["use_ball_as_particle"];
xt::pyarray<double>& ball_center = args.m_darray["ball_center"];
xt::pyarray<double>& ball_radius = args.m_darray["ball_radius"];
xt::pyarray<double>& ball_velocity = args.m_darray["ball_velocity"];
xt::pyarray<double>& ball_angular_velocity = args.m_darray["ball_angular_velocity"];
xt::pyarray<double>& phisError = args.m_darray["phisError"];
xt::pyarray<double>& phisErrorNodal = args.m_darray["phisErrorNodal"];
int USE_SUPG = args.m_iscalar["USE_SUPG"];
int ARTIFICIAL_VISCOSITY = args.m_iscalar["ARTIFICIAL_VISCOSITY"];
double cMax = args.m_dscalar["cMax"];
double cE = args.m_dscalar["cE"];
int MULTIPLY_EXTERNAL_FORCE_BY_DENSITY = args.m_iscalar["MULTIPLY_EXTERNAL_FORCE_BY_DENSITY"];
xt::pyarray<double>& forcex = args.m_darray["forcex"];
xt::pyarray<double>& forcey = args.m_darray["forcey"];
xt::pyarray<double>& forcez = args.m_darray["forcez"];
int KILL_PRESSURE_TERM = args.m_iscalar["KILL_PRESSURE_TERM"];
double dt = args.m_dscalar["dt"];
xt::pyarray<double>& quantDOFs = args.m_darray["quantDOFs"];
int MATERIAL_PARAMETERS_AS_FUNCTION = args.m_iscalar["MATERIAL_PARAMETERS_AS_FUNCTION"];
xt::pyarray<double>& density_as_function = args.m_darray["density_as_function"];
xt::pyarray<double>& dynamic_viscosity_as_function = args.m_darray["dynamic_viscosity_as_function"];
xt::pyarray<double>& ebqe_density_as_function = args.m_darray["ebqe_density_as_function"];
xt::pyarray<double>& ebqe_dynamic_viscosity_as_function = args.m_darray["ebqe_dynamic_viscosity_as_function"];
double order_polynomial = args.m_dscalar["order_polynomial"];
xt::pyarray<double>& isActiveDOF = args.m_darray["isActiveDOF"];
int USE_SBM = args.m_iscalar["USE_SBM"];
xt::pyarray<double>& ncDrag = args.m_darray["ncDrag"];
xt::pyarray<double>& betaDrag = args.m_darray["betaDrag"];
xt::pyarray<double>& vos_vel_nodes = args.m_darray["vos_vel_nodes"];
xt::pyarray<double>& entropyResidualPerNode = args.m_darray["entropyResidualPerNode"];
xt::pyarray<double>& laggedEntropyResidualPerNode = args.m_darray["laggedEntropyResidualPerNode"];
xt::pyarray<double>& uStar_dMatrix = args.m_darray["uStar_dMatrix"];
xt::pyarray<double>& vStar_dMatrix = args.m_darray["vStar_dMatrix"];
xt::pyarray<double>& wStar_dMatrix = args.m_darray["wStar_dMatrix"];
int numDOFs_1D = args.m_iscalar["numDOFs_1D"];
int NNZ_1D = args.m_iscalar["NNZ_1D"];
xt::pyarray<int>& csrRowIndeces_1D = args.m_iarray["csrRowIndeces_1D"];
xt::pyarray<int>& csrColumnOffsets_1D = args.m_iarray["csrColumnOffsets_1D"];
xt::pyarray<int>& rowptr_1D = args.m_iarray["rowptr_1D"];
xt::pyarray<int>& colind_1D = args.m_iarray["colind_1D"];
xt::pyarray<double>& isBoundary_1D = args.m_darray["isBoundary_1D"];
int INT_BY_PARTS_PRESSURE = args.m_iscalar["INT_BY_PARTS_PRESSURE"];
gf.useExact=useExact;
gf_s.useExact=useExact;
surrogate_boundaries.clear();
surrogate_boundary_elements.clear();
surrogate_boundary_particle.clear();
double cut_cell_boundary_length=0.0, p_force_x=0.0, p_force_y=0.0;
register double element_uStar_He[nElements_global], element_vStar_He[nElements_global];
uStar_hi.resize(numDOFs_1D,0.0);
vStar_hi.resize(numDOFs_1D,0.0);
den_hi.resize(numDOFs_1D,0.0);
uStar_min_hiHe.resize(numDOFs_1D,0.0);
vStar_min_hiHe.resize(numDOFs_1D,0.0);
uStar_gamma.resize(numDOFs_1D,0.0);
vStar_gamma.resize(numDOFs_1D,0.0);
TransportMatrix.resize(NNZ_1D,0.0);
TransposeTransportMatrix.resize(NNZ_1D,0.0);
uStar_psi.resize(numDOFs_1D,0.0);
vStar_psi.resize(numDOFs_1D,0.0);
if (ARTIFICIAL_VISCOSITY==3 || ARTIFICIAL_VISCOSITY==4)
{
if (TransportMatrix.size() != NNZ_1D)
TransportMatrix.resize(NNZ_1D);
if (TransposeTransportMatrix.size() != NNZ_1D)
TransposeTransportMatrix.resize(NNZ_1D);
if (psi.size() != numDOFs_1D)
psi.resize(numDOFs_1D);
for (int i=0; i<NNZ_1D; i++)
{
uStar_dMatrix[i]=0.;
vStar_dMatrix[i]=0.;
TransportMatrix[i] = 0.;
TransposeTransportMatrix[i] = 0.;
}
for (int i=0; i<numDOFs_1D; i++)
{
uStar_min_hiHe[i] = 1E100;
vStar_min_hiHe[i] = 1E100;
entropyResidualPerNode[i]=0.;
uStar_hi[i] = 0.;
vStar_hi[i] = 0.;
den_hi[i] = 0.;
}
}
//
//loop over elements to compute volume integrals and load them into element and global residual
//
double mesh_volume_conservation=0.0,
mesh_volume_conservation_weak=0.0,
mesh_volume_conservation_err_max=0.0,
mesh_volume_conservation_err_max_weak=0.0;
double globalConservationError=0.0;
const int nQuadraturePoints_global(nElements_global*nQuadraturePoints_element);
for(int eN=0;eN<nElements_global;eN++)
{
register double elementTransport[nDOF_test_element][nDOF_trial_element];
register double elementTransposeTransport[nDOF_test_element][nDOF_trial_element];
//declare local storage for element residual and initialize
register double elementResidual_p[nDOF_test_element],elementResidual_mesh[nDOF_test_element],
elementResidual_u[nDOF_test_element],
elementResidual_v[nDOF_test_element],
mom_u_source_i[nDOF_test_element],
mom_v_source_i[nDOF_test_element],
betaDrag_i[nDOF_test_element],
vos_i[nDOF_test_element],
phisErrorElement[nDOF_test_element],
//elementResidual_w[nDOF_test_element],
elementEntropyResidual[nDOF_test_element],
eps_rho,eps_mu;
//const double* elementResidual_w(NULL);
double element_active=1.0;//use 1 since by default it is ibm
double mesh_volume_conservation_element=0.0,
mesh_volume_conservation_element_weak=0.0;
// for entropy viscosity
double linVisc_eN = 0, nlinVisc_eN_num = 0, nlinVisc_eN_den = 0;
// for hessians of uStar
double det_hess_uStar_Ke=0.0, det_hess_vStar_Ke=0.0, area_Ke=0.0;
for (int i=0;i<nDOF_test_element;i++)
{
int eN_i = eN*nDOF_test_element+i;
elementResidual_p_save[eN_i]=0.0;
elementResidual_mesh[i]=0.0;
elementResidual_p[i]=0.0;
elementResidual_u[i]=0.0;
elementResidual_v[i]=0.0;
mom_u_source_i[i]=0.0;
mom_v_source_i[i]=0.0;
betaDrag_i[i]=0.0;
vos_i[i]=0.0;
phisErrorElement[i]=0.0;
/* elementResidual_w[i]=0.0; */
elementEntropyResidual[i]=0.0;
if (ARTIFICIAL_VISCOSITY==3 || ARTIFICIAL_VISCOSITY==4)
{
for (int j=0;j<nDOF_trial_element;j++)
{
elementTransport[i][j]=0.0;
elementTransposeTransport[i][j]=0.0;
}
}
}//i
//Use for plotting result
if(use_ball_as_particle==1)
{
for (int I=0;I<nDOF_mesh_trial_element;I++)
get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(),
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+0],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+1],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+2],
phi_solid_nodes[mesh_l2g[eN*nDOF_mesh_trial_element+I]]);
}
if(CUT_CELL_INTEGRATION > 0)
{
//
//detect cut cells, for unfitted fem we want all cells cut by phi=0 or with phi=0 lying on any boundary
//
double _distance[nDOF_mesh_trial_element]={0.0};
int pos_counter=0;
for (int I=0;I<nDOF_mesh_trial_element;I++)
{
if(use_ball_as_particle==1)
{
get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(),
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+0],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+1],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+2],
_distance[I]);
}
else
{
_distance[I] = phi_solid_nodes[mesh_l2g[eN*nDOF_mesh_trial_element+I]];
}
if ( _distance[I] > 0)//fully in fluid
pos_counter++;
}
if (pos_counter == 3)
{
element_active = 1.0;
}
else if (pos_counter == 0)
{
element_active = 1.0;
}
else
{
element_active = 1.0;//for now leave all elements active
//P1 interpolation operator; only 2D for now
double GI[6*3];//3 DOF to 6DOF for linear interpolation onto 4T refinement
double sub_mesh_dof[6*3], sub_u_dof[15], sub_v_dof[15], sub_phi_dof[6], sub_p_dof[6];//6 3D points
int boundaryNodes[6] = {0,0,0,0,0,0};
std::vector<int> ls_nodes;
for (int I=0;I<nDOF_mesh_trial_element;I++)
{
for (int K=0;K<nDOF_mesh_trial_element;K++)
{
GI[I*3+K] = 0.0;
if (I==K)
{
GI[I*3+K] = 1.0;
}
}
const double eps = 1.0e-4;
double delta_phi=0.0,theta;
delta_phi = _distance[(I+1)%3] - _distance[I];
if (fabs(delta_phi) > eps)//level sets are not parallel to edge
//need tolerance selection guidance
{
theta = -_distance[I]/delta_phi;//zero level set is at theta*xIp1+(1-theta)*xI
if (theta > 1.0-eps || theta < eps)//zero level does NOT intersect between nodes; it may got through a node
{
if (theta > 1.0-eps && theta <= 1.0)//
{
ls_nodes.push_back((I+1)%3);
//todo, fix connectivity for this case--can't use 4T
assert(false);
}
else if (theta > 0.0 && theta < eps)//
{
ls_nodes.push_back(I);
assert(false);
}
else
theta = 0.5;//just put the subelement node at midpoint
}
else
{
boundaryNodes[3+I]=1;
ls_nodes.push_back(3+I);
}
}
else //level set lies on edge
{
theta = 0.5;
if (fabs(_distance[I]) <= eps) //edge IS the zero level set
{
boundaryNodes[I]=1;
boundaryNodes[3+I]=1;
boundaryNodes[(I+1)%3]=1;
ls_nodes.push_back(I);
ls_nodes.push_back((I+1)%3);
}
}
assert(theta <= 1.0);
GI[3*3 + I*3 + I] = 1.0-theta;
GI[3*3 + I*3 + (I+1)%3] = theta;
GI[3*3 + I*3 + (I+2)%3] = 0.0;
}
if (ls_nodes.size() != 2)
{
std::cout<<"level set nodes not 2 "<<ls_nodes.size()<<std::endl;
for(int i=0;i<ls_nodes.size();i++)
std::cout<<ls_nodes[i]<<std::endl;
std::sort(ls_nodes.begin(),ls_nodes.end());
}
int sub_mesh_l2g[12] = {0,3,5,
1,4,3,
2,5,4,
3,4,5};
for (int I=0; I<6; I++)
{
sub_phi_dof[I] = 0.0;
sub_p_dof[I] = 0.0;
for (int K=0; K<3; K++)
sub_mesh_dof[I*3+K] = 0.0;
for (int J=0; J<3; J++)
{
for (int K=0; K<3; K++)
{
sub_mesh_dof[I*3+K] += GI[I*3+J]*mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+J]+K];
}
sub_phi_dof[I] += GI[I*3+J]*phi_solid_nodes[mesh_l2g[eN*nDOF_mesh_trial_element+J]];
sub_p_dof[I] += GI[I*3+J]*p_dof[p_l2g[eN*nDOF_per_element_pressure+J]];
}
}
int L = ls_nodes[0], R=ls_nodes[1];
double DX=sub_mesh_dof[L*3+0] - sub_mesh_dof[R*3+0];
double DY=sub_mesh_dof[L*3+1] - sub_mesh_dof[R*3+1];
double DS = std::sqrt(DX*DX+DY*DY);
double nx = -DY/DS, ny = DX/DS;
double nxL,nyL,nxR,nyR;
get_normal_to_ith_ball(nParticles,ball_center.data(),ball_radius.data(),
0,
sub_mesh_dof[L*3+0],sub_mesh_dof[L*3+1],0.0,
nxL,nyL);
get_normal_to_ith_ball(nParticles,ball_center.data(),ball_radius.data(),
0,
sub_mesh_dof[R*3+0],sub_mesh_dof[R*3+1],0.0,
nxR,nyR);
//std::cout<<"dot L "<<nx_tmp*nxL+ny_tmp*nyL<<std::endl;
//std::cout<<"dot R "<<nx_tmp*nxR+ny_tmp*nyR<<std::endl;
double n_fluid_sign = -sgn(nx*0.5*(nxL+nxR)+ny*0.5*(nyL+nyR));
nx*=n_fluid_sign;
ny*=n_fluid_sign;
//double dot_test=std::fabs(nx_tmp*nx+ny_tmp*ny);
//assert(dot_test > 1.0-1.0e-4 && dot_test < 1.0 + 1.0e-4);
cut_cell_boundary_length += DS;
p_force_x += sub_p_dof[L]*nx*0.5*DS + sub_p_dof[R]*nx*0.5*DS;
p_force_y += sub_p_dof[L]*ny*0.5*DS + sub_p_dof[R]*ny*0.5*DS;
//TODO for P2
//1. Now define the Lagrange nodes for P2 on the submesh X
//2. Define and evaluate the P2 trial functions for the parent element at the new submesh P2 nodes. X
//3. Form the G2I interpolation operator X
//4. Interpolate the P2 DOF from the parent element to the submesh DOF X
double G2I[15*6];//6 DOF to 15 DOF for quadratic interpolation onto 4T refinement
double lagrangeNodes[9*3];//9 new quadratic nodes in addition to the 6 we have
for (int K=0;K<3;K++)
{
lagrangeNodes[0*3+K] = 0.5*(sub_mesh_dof[0*3+K] + sub_mesh_dof[3*3+0*3+K]);
lagrangeNodes[1*3+K] = 0.5*(sub_mesh_dof[1*3+K] + sub_mesh_dof[3*3+0*3+K]);
lagrangeNodes[2*3+K] = 0.5*(sub_mesh_dof[1*3+K] + sub_mesh_dof[3*3+1*3+K]);
lagrangeNodes[3*3+K] = 0.5*(sub_mesh_dof[2*3+K] + sub_mesh_dof[3*3+1*3+K]);
lagrangeNodes[4*3+K] = 0.5*(sub_mesh_dof[2*3+K] + sub_mesh_dof[3*3+2*3+K]);
lagrangeNodes[5*3+K] = 0.5*(sub_mesh_dof[0*3+K] + sub_mesh_dof[3*3+2*3+K]);
lagrangeNodes[6*3+K] = 0.5*(sub_mesh_dof[3*3+0*3+K] + sub_mesh_dof[3*3+1*3+K]);
lagrangeNodes[7*3+K] = 0.5*(sub_mesh_dof[3*3+1*3+K] + sub_mesh_dof[3*3+2*3+K]);
lagrangeNodes[8*3+K] = 0.5*(sub_mesh_dof[3*3+2*3+K] + sub_mesh_dof[3*3+0*3+K]);
}
double lambda[3];
for (int I=0;I<6;I++)
{
baryCoords(&sub_mesh_dof[0],&sub_mesh_dof[1*3],&sub_mesh_dof[2*3],&sub_mesh_dof[I*3],lambda);
//std::cout<<"lambda"<<'\t'<<lambda[0]<<'\t'<<lambda[1]<<'\t'<<lambda[2]<<std::endl;
G2I[I*6+0] = lambda[0]*(2.0*lambda[0] - 1.0);
G2I[I*6+1] = lambda[1]*(2.0*lambda[1] - 1.0);
G2I[I*6+2] = lambda[2]*(2.0*lambda[2] - 1.0);
G2I[I*6+3] = 4.0*lambda[0]*lambda[1];
G2I[I*6+4] = 4.0*lambda[1]*lambda[2];
G2I[I*6+5] = 4.0*lambda[2]*lambda[0];
}
for (int I=0;I<9;I++)
{
baryCoords(&sub_mesh_dof[0],&sub_mesh_dof[1*3],&sub_mesh_dof[2*3],&lagrangeNodes[I*3],lambda);
G2I[6*6 + I*6 + 0] = lambda[0]*(2.0*lambda[0] - 1.0);
G2I[6*6 + I*6 + 1] = lambda[1]*(2.0*lambda[1] - 1.0);
G2I[6*6 + I*6 + 2] = lambda[2]*(2.0*lambda[2] - 1.0);
G2I[6*6 + I*6 + 3] = 4.0*lambda[0]*lambda[1];
G2I[6*6 + I*6 + 4] = 4.0*lambda[1]*lambda[2];
G2I[6*6 + I*6 + 5] = 4.0*lambda[2]*lambda[0];
}
for (int I=0; I<15; I++)
{
sub_u_dof[I] = 0.0;
sub_v_dof[I] = 0.0;
for (int J=0; J<6; J++)
{
sub_u_dof[I] += G2I[I*6+J]*u_dof[vel_l2g[eN*nDOF_trial_element+J]];
sub_v_dof[I] += G2I[I*6+J]*v_dof[vel_l2g[eN*nDOF_trial_element+J]];
}
}
for (int esN=0;esN<4;esN++)
{
std::cout<<sub_mesh_l2g[esN*3]<<'\t'<<sub_mesh_l2g[esN*3+1]<<'\t'<<sub_mesh_l2g[esN*3+2]<<std::endl;
}
for (int I=0; I<6; I++)
{
std::cout<<sub_mesh_dof[I*3+0]<<'\t'<<sub_mesh_dof[I*3+1]<<'\t'<<sub_mesh_dof[I*3+2]<<'\t'<<boundaryNodes[I]<<'\t'<<sub_phi_dof[I]<<'\t'<<sub_p_dof[I]<<'\t'<<sub_u_dof[I]<<'\t'<<sub_v_dof[I]<<'\t'<<G2I[I*6+0]<<'\t'<<G2I[I*6+1]<<'\t'<<G2I[I*6+2]<<'\t'<<G2I[I*6+3]<<'\t'<<G2I[I*6+4]<<'\t'<<G2I[I*6+5]<<std::endl;
}
}
}
if(USE_SBM>0)
{
//
//detect cut cells
//
double _distance[nDOF_mesh_trial_element]={0.0};
int pos_counter=0;
for (int I=0;I<nDOF_mesh_trial_element;I++)
{
if(use_ball_as_particle==1)
{
get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(),
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+0],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+1],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+2],
_distance[I]);
}
else
{
_distance[I] = phi_solid_nodes[mesh_l2g[eN*nDOF_mesh_trial_element+I]];
}
if ( _distance[I] >= 0)
pos_counter++;
}
if (pos_counter == 2)
{
element_active=0.0;
int opp_node=-1;
for (int I=0;I<nDOF_mesh_trial_element;I++)
{
// quantDOFs[vel_l2g[eN*nDOF_trial_element + I]] = 2.0;//for test
if (_distance[I] < 0)
{
opp_node = I;
// quantDOFs[vel_l2g[eN*nDOF_trial_element + I]] = 1.0;//for test
}
}
assert(opp_node >=0);
assert(opp_node <nDOF_mesh_trial_element);
//For parallel. Two reasons:
//if none of nodes of this edge is owned by this processor,
//1. The surrogate_boundary_elements corresponding to this edge is -1, which gives 0 JacDet and infty h_penalty.
//2. there is no contribution of the integral over this edge to Jacobian and residual.
const int ebN = elementBoundariesArray[eN*nDOF_mesh_trial_element+opp_node];//only works for simplices
const int eN_oppo = (eN == elementBoundaryElementsArray[ebN*2+0])?elementBoundaryElementsArray[ebN*2+1]:elementBoundaryElementsArray[ebN*2+0];
if((mesh_l2g[eN*nDOF_mesh_trial_element+(opp_node+1)%3]<nNodes_owned
|| mesh_l2g[eN*nDOF_mesh_trial_element+(opp_node+2)%3]<nNodes_owned)
&& eN_oppo!= -1)
{
surrogate_boundaries.push_back(ebN);
//now find which element neighbor this element is
//YY: what if this face is a boundary face?
if (eN == elementBoundaryElementsArray[ebN*2+0])//should be ebN
surrogate_boundary_elements.push_back(1);
else
surrogate_boundary_elements.push_back(0);
//check which particle this surrogate edge is related to.
int j=-1;
if(use_ball_as_particle==1)
{
double middle_point_coord[3]={0.0};
double middle_point_distance;
middle_point_coord[0] = 0.5*(mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+(opp_node+1)%3]+0]+mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+(opp_node+2)%3]+0]);
middle_point_coord[1] = 0.5*(mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+(opp_node+1)%3]+1]+mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+(opp_node+2)%3]+1]);
j = get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(),
middle_point_coord[0],middle_point_coord[1],middle_point_coord[2],
middle_point_distance);
}
else
{
//The method is to check one quadrature point inside of this element.
//It works based on the assumption that the distance between any two particles
//is larger than 2*h_min, otherwise it depends on the choice of the quadrature point
//or one edge belongs to two particles .
//But in any case, phi_s is well defined as the minimum.
double distance=1e10, distance_to_ith_particle;
for (int i=0;i<nParticles;++i)
{
distance_to_ith_particle=particle_signed_distances[i*nElements_global*nQuadraturePoints_element
+eN*nQuadraturePoints_element
+0];//0-th quadrature point
if (distance_to_ith_particle<distance)
{
distance = distance_to_ith_particle;
j = i;
}
}
}
surrogate_boundary_particle.push_back(j);
}else{
//If the integral over the surrogate boundary is needed, we have to make sure all edges are in surrogate_boundaries,
//which is based on the assumption that if none of its nodes is owned by the processor, then the edge is not owned
//by the processor. This assert is used to make sure this is the case.
if(ebN<nElementBoundaries_owned)//eN_oppo ==-1
{
assert(eN_oppo==-1);
}
}
}
else if (pos_counter == 3)
{
element_active=1.0;
for (int i=0;i<nDOF_test_element;i++)
{
isActiveDOF[offset_u+stride_u*vel_l2g[eN*nDOF_trial_element + i]]=1.0;
isActiveDOF[offset_v+stride_v*vel_l2g[eN*nDOF_trial_element + i]]=1.0;
}
}
else
{
element_active=0.0;
}
}
double element_phi[nDOF_mesh_trial_element], element_phi_s[nDOF_mesh_trial_element];
for (int j=0;j<nDOF_mesh_trial_element;j++)
{
register int eN_j = eN*nDOF_mesh_trial_element+j;
element_phi[j] = phi_dof[p_l2g[eN_j]];
element_phi_s[j] = phi_solid_nodes[p_l2g[eN_j]];
}
double element_nodes[nDOF_mesh_trial_element*3];
for (int i=0;i<nDOF_mesh_trial_element;i++)
{
register int eN_i=eN*nDOF_mesh_trial_element+i;
for(int I=0;I<3;I++)
element_nodes[i*3 + I] = mesh_dof[mesh_l2g[eN_i]*3 + I];
}//i
gf_s.calculate(element_phi_s, element_nodes, x_ref.data(), false);
gf.calculate(element_phi, element_nodes, x_ref.data(), false);
//
//loop over quadrature points and compute integrands
//
for(int k=0;k<nQuadraturePoints_element;k++)
{
gf.set_quad(k);
gf_s.set_quad(k);
//compute indices and declare local storage
register int eN_k = eN*nQuadraturePoints_element+k,
eN_k_nSpace = eN_k*nSpace,
eN_k_3d = eN_k*3,
eN_nDOF_trial_element = eN*nDOF_trial_element;
register double p=0.0,u=0.0,v=0.0,w=0.0,un=0.0,vn=0.0,wn=0.0,
grad_p[nSpace],grad_u[nSpace],grad_v[nSpace],grad_w[nSpace],
hess_u[nSpace2],hess_v[nSpace2],
mom_u_acc=0.0,
dmom_u_acc_u=0.0,
mom_v_acc=0.0,
dmom_v_acc_v=0.0,
mom_w_acc=0.0,
dmom_w_acc_w=0.0,
mass_adv[nSpace],
dmass_adv_u[nSpace],
dmass_adv_v[nSpace],
dmass_adv_w[nSpace],
mom_u_adv[nSpace],
dmom_u_adv_u[nSpace],
dmom_u_adv_v[nSpace],
dmom_u_adv_w[nSpace],
mom_v_adv[nSpace],
dmom_v_adv_u[nSpace],
dmom_v_adv_v[nSpace],
dmom_v_adv_w[nSpace],
mom_w_adv[nSpace],
dmom_w_adv_u[nSpace],
dmom_w_adv_v[nSpace],
dmom_w_adv_w[nSpace],
mom_uu_diff_ten[nSpace],
mom_vv_diff_ten[nSpace],
mom_ww_diff_ten[nSpace],
mom_uv_diff_ten[1],
mom_uw_diff_ten[1],
mom_vu_diff_ten[1],
mom_vw_diff_ten[1],
mom_wu_diff_ten[1],
mom_wv_diff_ten[1],
mom_u_source=0.0,
mom_v_source=0.0,
mom_w_source=0.0,
mom_u_ham=0.0,
dmom_u_ham_grad_p[nSpace],
dmom_u_ham_grad_u[nSpace],
mom_v_ham=0.0,
dmom_v_ham_grad_p[nSpace],
dmom_v_ham_grad_v[nSpace],
mom_w_ham=0.0,
dmom_w_ham_grad_p[nSpace],
dmom_w_ham_grad_w[nSpace],
mom_u_acc_t=0.0,
dmom_u_acc_u_t=0.0,
mom_v_acc_t=0.0,
dmom_v_acc_v_t=0.0,
mom_w_acc_t=0.0,
dmom_w_acc_w_t=0.0,
pdeResidual_p=0.0,
pdeResidual_u=0.0,
pdeResidual_v=0.0,
pdeResidual_w=0.0,
Lstar_u_p[nDOF_test_element],
Lstar_v_p[nDOF_test_element],
Lstar_w_p[nDOF_test_element],
Lstar_u_u[nDOF_test_element],
Lstar_v_v[nDOF_test_element],
Lstar_w_w[nDOF_test_element],
Lstar_p_u[nDOF_test_element],
Lstar_p_v[nDOF_test_element],
Lstar_p_w[nDOF_test_element],
subgridError_p=0.0,
subgridError_u=0.0,
subgridError_v=0.0,
subgridError_w=0.0,
tau_p=0.0,tau_p0=0.0,tau_p1=0.0,
tau_v=0.0,tau_v0=0.0,tau_v1=0.0,
jac[nSpace*nSpace],
jacDet,
jacInv[nSpace*nSpace],
p_grad_trial[nDOF_trial_element*nSpace],vel_grad_trial[nDOF_trial_element*nSpace],
vel_hess_trial[nDOF_trial_element*nSpace2],
p_test_dV[nDOF_trial_element],vel_test_dV[nDOF_trial_element],
p_grad_test_dV[nDOF_test_element*nSpace],vel_grad_test_dV[nDOF_test_element*nSpace],
u_times_vel_grad_test_dV[nDOF_test_element*nSpace], // For entropy residual
v_times_vel_grad_test_dV[nDOF_test_element*nSpace], // For entropy residual
dV,x,y,z,xt,yt,zt,
//
porosity,
//meanGrainSize,
mass_source,
dmom_u_source[nSpace],
dmom_v_source[nSpace],
dmom_w_source[nSpace],
//
velStar[nSpace], hess_uStar[nSpace2], hess_vStar[nSpace2],
//
G[nSpace*nSpace],G_dd_G,tr_G,norm_Rv,h_phi, dmom_adv_star[nSpace],dmom_adv_sge[nSpace];
//get jacobian, etc for mapping reference element
ck.calculateMapping_element(eN,
k,
mesh_dof.data(),
mesh_l2g.data(),
mesh_trial_ref.data(),
mesh_grad_trial_ref.data(),
jac,
jacDet,
jacInv,
x,y,z);
ck.calculateH_element(eN,
k,
nodeDiametersArray.data(),
mesh_l2g.data(),
mesh_trial_ref.data(),
h_phi);
ck.calculateMappingVelocity_element(eN,
k,
mesh_velocity_dof.data(),
mesh_l2g.data(),
mesh_trial_ref.data(),
xt,yt,zt);
//xt=0.0;yt=0.0;zt=0.0;
//std::cout<<"xt "<<xt<<'\t'<<yt<<'\t'<<zt<<std::endl;
//get the physical integration weight
dV = fabs(jacDet)*dV_ref[k];
ck.calculateG(jacInv,G,G_dd_G,tr_G);
//ck.calculateGScale(G,&normal_phi[eN_k_nSpace],h_phi);
eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
double particle_eps = particle_epsFact*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
//get the trial function gradients
/* ck.gradTrialFromRef(&p_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); */
ck.gradTrialFromRef(&vel_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
ck.hessTrialFromRef(&vel_hess_trial_ref[k*nDOF_trial_element*nSpace2],jacInv,vel_hess_trial);
//get the solution
/* ck.valFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],&p_trial_ref[k*nDOF_trial_element],p); */
p = q_p[eN_k];
// get solution at quad points
ck.valFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u);
ck.valFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v);
/* ck.valFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],w); */
// get old solution at quad points
ck.valFromDOF(u_dof_old.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],un);
ck.valFromDOF(v_dof_old.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],vn);
/* ck.valFromDOF(w_dof_old,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],wn); */
//get the solution gradients
/* ck.gradFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],p_grad_trial,grad_p); */
for (int I=0;I<nSpace;I++)
grad_p[I] = q_grad_p[eN_k_nSpace + I];
ck.gradFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_u);
ck.gradFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_v);
ck.hessFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_hess_trial,hess_u);
ck.hessFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_hess_trial,hess_v);
ck.hessFromDOF(uStar_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_hess_trial,hess_uStar);
ck.hessFromDOF(vStar_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_hess_trial,hess_vStar);
/* ck.gradFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_w); */
//precalculate test function products with integration weights
for (int j=0;j<nDOF_trial_element;j++)
{
/* p_test_dV[j] = p_test_ref[k*nDOF_trial_element+j]*dV; */
vel_test_dV[j] = vel_test_ref[k*nDOF_trial_element+j]*dV;
for (int I=0;I<nSpace;I++)
{
/* p_grad_test_dV[j*nSpace+I] = p_grad_trial[j*nSpace+I]*dV;//cek warning won't work for Petrov-Galerkin */
vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;//cek warning won't work for Petrov-Galerkin
if (ARTIFICIAL_VISCOSITY==4)
{
// mql: for entropy residual. grad(u*phi) and grad(v*phi)
u_times_vel_grad_test_dV[j*nSpace+I] =
u*vel_grad_trial[j*nSpace+I]*dV + vel_test_dV[j]*grad_u[I];
v_times_vel_grad_test_dV[j*nSpace+I] =
v*vel_grad_trial[j*nSpace+I]*dV + vel_test_dV[j]*grad_v[I];
/*w_times_vel_grad_test_dV[j*nSpace+I] =
w*vel_grad_trial[j*nSpace+I]*dV + vel_test_dV[j]*grad_w[I];*/
}
}
}
// compute determinant of Hessians
if (ARTIFICIAL_VISCOSITY==3)
{
det_hess_uStar_Ke += (hess_uStar[0]*hess_uStar[3] - hess_uStar[2]*hess_uStar[1])*dV;
det_hess_vStar_Ke += (hess_vStar[0]*hess_vStar[3] - hess_vStar[2]*hess_vStar[1])*dV;
area_Ke += dV;
}
//cek hack
double div_mesh_velocity=0.0;
int NDOF_MESH_TRIAL_ELEMENT=3;
for (int j=0;j<NDOF_MESH_TRIAL_ELEMENT;j++)
{
int eN_j=eN*NDOF_MESH_TRIAL_ELEMENT+j;
div_mesh_velocity +=
mesh_velocity_dof[mesh_l2g[eN_j]*3+0]*vel_grad_trial[j*nSpace+0] +
mesh_velocity_dof[mesh_l2g[eN_j]*3+1]*vel_grad_trial[j*nSpace+1];
}
mesh_volume_conservation_element += (alphaBDF*(dV-q_dV_last[eN_k])/dV - div_mesh_velocity)*dV;
div_mesh_velocity = DM3*div_mesh_velocity + (1.0-DM3)*alphaBDF*(dV-q_dV_last[eN_k])/dV;
//VRANS
porosity = 1.0 - q_vos[eN_k];
//meanGrainSize = q_meanGrain[eN_k];
//
q_x[eN_k_3d+0]=x;
q_x[eN_k_3d+1]=y;
/* q_x[eN_k_3d+2]=z; */
//
//calculate pde coefficients at quadrature points
//
double distance_to_omega_solid = 1e10;
if(use_ball_as_particle==1)
{
get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(),
x,y,z,
distance_to_omega_solid);
}
else
{
for (int i = 0; i < nParticles; i++)
{
double distance_to_i_th_solid = particle_signed_distances[i * nElements_global * nQuadraturePoints_element + eN_k];
distance_to_omega_solid = (distance_to_i_th_solid < distance_to_omega_solid)?distance_to_i_th_solid:distance_to_omega_solid;
}
}
phi_solid[eN_k] = distance_to_omega_solid;//save it
//
//calculate pde coefficients at quadrature points
//
evaluateCoefficients(eps_rho,
eps_mu,
particle_eps,
sigma,
rho_0,
nu_0,
rho_1,
nu_1,
elementDiameter[eN],
smagorinskyConstant,
turbulenceClosureModel,
g.data(),
useVF,
vf[eN_k],
phi[eN_k],
&normal_phi[eN_k_nSpace],
distance_to_omega_solid,
kappa_phi[eN_k],
//VRANS
porosity,
//
p,
grad_p,
grad_u,
grad_v,
grad_w,
u,
v,
w,
q_velocity_sge[eN_k_nSpace+0],
q_velocity_sge[eN_k_nSpace+1],
q_velocity_sge[eN_k_nSpace+1],//hack, shouldn't be used
q_eddy_viscosity[eN_k],
mom_u_acc,
dmom_u_acc_u,
mom_v_acc,
dmom_v_acc_v,
mom_w_acc,
dmom_w_acc_w,
mass_adv,
dmass_adv_u,
dmass_adv_v,
dmass_adv_w,
mom_u_adv,
dmom_u_adv_u,
dmom_u_adv_v,
dmom_u_adv_w,
mom_v_adv,
dmom_v_adv_u,
dmom_v_adv_v,
dmom_v_adv_w,
mom_w_adv,
dmom_w_adv_u,
dmom_w_adv_v,
dmom_w_adv_w,
mom_uu_diff_ten,
mom_vv_diff_ten,
mom_ww_diff_ten,
mom_uv_diff_ten,
mom_uw_diff_ten,
mom_vu_diff_ten,
mom_vw_diff_ten,
mom_wu_diff_ten,
mom_wv_diff_ten,
mom_u_source,
mom_v_source,
mom_w_source,
mom_u_ham,
dmom_u_ham_grad_p,
dmom_u_ham_grad_u,
mom_v_ham,
dmom_v_ham_grad_p,
dmom_v_ham_grad_v,
mom_w_ham,
dmom_w_ham_grad_p,
dmom_w_ham_grad_w,
q_rho[eN_k],
q_nu[eN_k],
KILL_PRESSURE_TERM,
MULTIPLY_EXTERNAL_FORCE_BY_DENSITY,
forcex[eN_k],
forcey[eN_k],
forcez[eN_k],
MATERIAL_PARAMETERS_AS_FUNCTION,
density_as_function[eN_k],
dynamic_viscosity_as_function[eN_k],
USE_SBM,
x,y,z,
use_ball_as_particle,
ball_center.data(),
ball_radius.data(),
ball_velocity.data(),
ball_angular_velocity.data(),
INT_BY_PARTS_PRESSURE);
//VRANS
mass_source = q_mass_source[eN_k];
for (int I=0;I<nSpace;I++)
{
dmom_u_source[I] = 0.0;
dmom_v_source[I] = 0.0;
dmom_w_source[I] = 0.0;
}
updateDarcyForchheimerTerms_Ergun(
q_dragAlpha[eN_k],
q_dragBeta[eN_k],
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
q_eddy_viscosity[eN_k],
useVF,
vf[eN_k],
phi[eN_k],
u,
v,
w,
q_velocity_sge[eN_k_nSpace+0],
q_velocity_sge[eN_k_nSpace+1],
q_velocity_sge[eN_k_nSpace+1],//hack, shouldn't be used
eps_solid[elementFlags[eN]],
porosity,
q_velocity_solid[eN_k_nSpace+0],
q_velocity_solid[eN_k_nSpace+1],
q_velocity_solid[eN_k_nSpace+1],//cek hack, should not be used
q_velocityStar_solid[eN_k_nSpace+0],
q_velocityStar_solid[eN_k_nSpace+1],
q_velocityStar_solid[eN_k_nSpace+1],//cek hack, should not be used
mom_u_source,
mom_v_source,
mom_w_source,
dmom_u_source,
dmom_v_source,
dmom_w_source,
q_grad_vos[eN_k_nSpace+0],
q_grad_vos[eN_k_nSpace+1],
q_grad_vos[eN_k_nSpace+1]);
double C_particles=0.0;
if(nParticles > 0 && USE_SBM==0)
updateSolidParticleTerms(eN < nElements_owned,
particle_nitsche,
dV,
nParticles,
nQuadraturePoints_global,
&particle_signed_distances[eN_k],
&particle_signed_distance_normals[eN_k_3d],
&particle_velocities[eN_k_3d],
particle_centroids.data(),
use_ball_as_particle,
ball_center.data(),
ball_radius.data(),
ball_velocity.data(),
ball_angular_velocity.data(),
porosity,
particle_penalty_constant/h_phi,
particle_alpha/h_phi,
particle_beta/h_phi,
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
useVF,
vf[eN_k],
phi[eN_k],
x,
y,
z,
p,
u,
v,
w,
q_velocity_sge[eN_k_nSpace+0],
q_velocity_sge[eN_k_nSpace+1],
q_velocity_sge[eN_k_nSpace+1],
particle_eps,
grad_u,
grad_v,
grad_w,
mom_u_source,
mom_v_source,
mom_w_source,
dmom_u_source,
dmom_v_source,
dmom_w_source,
mom_u_adv,
mom_v_adv,
mom_w_adv,
dmom_u_adv_u,
dmom_v_adv_v,
dmom_w_adv_w,
mom_u_ham,
dmom_u_ham_grad_u,
mom_v_ham,
dmom_v_ham_grad_v,
mom_w_ham,
dmom_w_ham_grad_w,
particle_netForces.data(),
particle_netMoments.data(),
particle_surfaceArea.data());
if(USE_SBM==2)
compute_force_around_solid(eN < nElements_owned,
dV,
nParticles,
nQuadraturePoints_global,
&particle_signed_distances[eN_k],
&particle_signed_distance_normals[eN_k_3d],
&particle_velocities[eN_k_3d],
particle_centroids.data(),
use_ball_as_particle,
ball_center.data(),
ball_radius.data(),
ball_velocity.data(),
ball_angular_velocity.data(),
particle_penalty_constant/h_phi,
particle_alpha/h_phi,
particle_beta/h_phi,
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
useVF,
vf[eN_k],
phi[eN_k],
x,
y,
z,
p,
u,
v,
w,
q_velocity_sge[eN_k_nSpace+0],
q_velocity_sge[eN_k_nSpace+1],
q_velocity_sge[eN_k_nSpace+1],
particle_eps,
grad_u,
grad_v,
grad_w,
particle_netForces.data(),
particle_netMoments.data());
//Turbulence closure model
if (turbulenceClosureModel >= 3)
{
const double c_mu = 0.09;//mwf hack
updateTurbulenceClosure(turbulenceClosureModel,
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
useVF,
vf[eN_k],
phi[eN_k],
porosity,
c_mu, //mwf hack
q_turb_var_0[eN_k],
q_turb_var_1[eN_k],
&q_turb_var_grad_0[eN_k_nSpace],
q_eddy_viscosity[eN_k],
mom_uu_diff_ten,
mom_vv_diff_ten,
mom_ww_diff_ten,
mom_uv_diff_ten,
mom_uw_diff_ten,
mom_vu_diff_ten,
mom_vw_diff_ten,
mom_wu_diff_ten,
mom_wv_diff_ten,
mom_u_source,
mom_v_source,
mom_w_source);
}
//
//save momentum for time history and velocity for subgrid error
//
q_mom_u_acc[eN_k] = mom_u_acc;
q_mom_v_acc[eN_k] = mom_v_acc;
/* q_mom_w_acc[eN_k] = mom_w_acc; */
//subgrid error uses grid scale velocity
q_mass_adv[eN_k_nSpace+0] = u;
q_mass_adv[eN_k_nSpace+1] = v;
/* q_mass_adv[eN_k_nSpace+2] = w; */
//
//moving mesh
//
mom_u_adv[0] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*xt; // multiply by rho*porosity. mql. CHECK.
mom_u_adv[1] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*yt;
/* mom_u_adv[2] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*zt; */
dmom_u_adv_u[0] -= MOVING_DOMAIN*dmom_u_acc_u*xt;
dmom_u_adv_u[1] -= MOVING_DOMAIN*dmom_u_acc_u*yt;
/* dmom_u_adv_u[2] -= MOVING_DOMAIN*dmom_u_acc_u*zt; */
mom_v_adv[0] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*xt;
mom_v_adv[1] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*yt;
/* mom_v_adv[2] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*zt; */
dmom_v_adv_v[0] -= MOVING_DOMAIN*dmom_v_acc_v*xt;
dmom_v_adv_v[1] -= MOVING_DOMAIN*dmom_v_acc_v*yt;
/* dmom_v_adv_v[2] -= MOVING_DOMAIN*dmom_v_acc_v*zt; */
/* mom_w_adv[0] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*xt; */
/* mom_w_adv[1] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*yt; */
/* mom_w_adv[2] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*zt; */
/* dmom_w_adv_w[0] -= MOVING_DOMAIN*dmom_w_acc_w*xt; */
/* dmom_w_adv_w[1] -= MOVING_DOMAIN*dmom_w_acc_w*yt; */
/* dmom_w_adv_w[2] -= MOVING_DOMAIN*dmom_w_acc_w*zt; */
//
//calculate time derivative at quadrature points
//
if (q_dV_last[eN_k] <= -100)
q_dV_last[eN_k] = dV;
q_dV[eN_k] = dV;
ck.bdf(alphaBDF,
q_mom_u_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV,
mom_u_acc,
dmom_u_acc_u,
mom_u_acc_t,
dmom_u_acc_u_t);
ck.bdf(alphaBDF,
q_mom_v_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV,
mom_v_acc,
dmom_v_acc_v,
mom_v_acc_t,
dmom_v_acc_v_t);
/* ck.bdf(alphaBDF, */
/* q_mom_w_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, */
/* mom_w_acc, */
/* dmom_w_acc_w, */
/* mom_w_acc_t, */
/* dmom_w_acc_w_t); */
/* // */
mom_u_acc_t *= dmom_u_acc_u; //multiply by rho*porosity. mql. CHECK.
mom_v_acc_t *= dmom_v_acc_v;
//calculate subgrid error (strong residual and adjoint)
//
//calculate strong residual
pdeResidual_p =
ck.Mass_strong(-q_dvos_dt[eN_k]) + // mql. CHECK.
ck.Advection_strong(dmass_adv_u,grad_u) +
ck.Advection_strong(dmass_adv_v,grad_v) +
/* ck.Advection_strong(dmass_adv_w,grad_w) + */
DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last[eN_k])/dV - div_mesh_velocity) +
//VRANS
ck.Reaction_strong(mass_source);
//
dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt);
dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt);
/* dmom_adv_sge[2] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+2] - MOVING_DOMAIN*zt); */
pdeResidual_u =
ck.Mass_strong(mom_u_acc_t) + // mql. CHECK.
ck.Advection_strong(dmom_adv_sge,grad_u) + //note here and below: same in cons. and non-cons.
ck.Hamiltonian_strong(dmom_u_ham_grad_p,grad_p) +
ck.Reaction_strong(mom_u_source) -
ck.Reaction_strong(u*div_mesh_velocity);
pdeResidual_v =
ck.Mass_strong(mom_v_acc_t) +
ck.Advection_strong(dmom_adv_sge,grad_v) +
ck.Hamiltonian_strong(dmom_v_ham_grad_p,grad_p) +
ck.Reaction_strong(mom_v_source) -
ck.Reaction_strong(v*div_mesh_velocity);
/* pdeResidual_w = ck.Mass_strong(dmom_w_acc_w*mom_w_acc_t) + */
/* ck.Advection_strong(dmom_adv_sge,grad_w) + */
/* ck.Hamiltonian_strong(dmom_w_ham_grad_p,grad_p) + */
/* ck.Reaction_strong(mom_w_source) - */
/* ck.Reaction_strong(w*div_mesh_velocity); */
//calculate tau and tau*Res
//cek debug
double tmpR=dmom_u_acc_u_t + dmom_u_source[0];
calculateSubgridError_tau(hFactor,
elementDiameter[eN],
tmpR,//dmom_u_acc_u_t,
dmom_u_acc_u,
dmom_adv_sge,
mom_uu_diff_ten[1],
dmom_u_ham_grad_p[0],
tau_v0,
tau_p0,
q_cfl[eN_k]);
calculateSubgridError_tau(Ct_sge,Cd_sge,
G,G_dd_G,tr_G,
tmpR,//dmom_u_acc_u_t,
dmom_adv_sge,
mom_uu_diff_ten[1],
dmom_u_ham_grad_p[0],
tau_v1,
tau_p1,
q_cfl[eN_k]);
tau_v = useMetrics*tau_v1+(1.0-useMetrics)*tau_v0;
tau_p = KILL_PRESSURE_TERM == 1 ? 0. : PSTAB*(useMetrics*tau_p1+(1.0-useMetrics)*tau_p0);
calculateSubgridError_tauRes(tau_p,
tau_v,
pdeResidual_p,
pdeResidual_u,
pdeResidual_v,
pdeResidual_w,
subgridError_p,
subgridError_u,
subgridError_v,
subgridError_w);
// velocity used in adjoint (VMS or RBLES, with or without lagging the grid scale velocity)
dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt + useRBLES*subgridError_u);
dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v);
/* dmom_adv_star[2] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+2] - MOVING_DOMAIN*zt + useRBLES*subgridError_w); */
mom_u_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge[eN_k_nSpace+0]);
mom_u_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge[eN_k_nSpace+0]);
/* mom_u_adv[2] += dmom_u_acc_u*(useRBLES*subgridError_w*q_velocity_sge[eN_k_nSpace+0]); */
// adjoint times the test functions
for (int i=0;i<nDOF_test_element;i++)
{
register int i_nSpace = i*nSpace;
/* Lstar_u_p[i]=ck.Advection_adjoint(dmass_adv_u,&p_grad_test_dV[i_nSpace]); */
/* Lstar_v_p[i]=ck.Advection_adjoint(dmass_adv_v,&p_grad_test_dV[i_nSpace]); */
/* Lstar_w_p[i]=ck.Advection_adjoint(dmass_adv_w,&p_grad_test_dV[i_nSpace]); */
//use the same advection adjoint for all three since we're approximating the linearized adjoint
Lstar_u_u[i]=ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
Lstar_v_v[i]=ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
/* Lstar_w_w[i]=ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]); */
Lstar_p_u[i]=ck.Hamiltonian_adjoint(dmom_u_ham_grad_p,&vel_grad_test_dV[i_nSpace]);
Lstar_p_v[i]=ck.Hamiltonian_adjoint(dmom_v_ham_grad_p,&vel_grad_test_dV[i_nSpace]);
/* Lstar_p_w[i]=ck.Hamiltonian_adjoint(dmom_w_ham_grad_p,&vel_grad_test_dV[i_nSpace]); */
//VRANS account for drag terms, diagonal only here ... decide if need off diagonal terms too
Lstar_u_u[i]+=ck.Reaction_adjoint(dmom_u_source[0],vel_test_dV[i]);
Lstar_v_v[i]+=ck.Reaction_adjoint(dmom_v_source[1],vel_test_dV[i]);
/* Lstar_w_w[i]+=ck.Reaction_adjoint(dmom_w_source[2],vel_test_dV[i]); */
//
}
if (ARTIFICIAL_VISCOSITY==0 || ARTIFICIAL_VISCOSITY==3 || ARTIFICIAL_VISCOSITY==4)
{
q_numDiff_u[eN_k] = 0;
q_numDiff_v[eN_k] = 0;
q_numDiff_w[eN_k] = 0;
}
else if (ARTIFICIAL_VISCOSITY==1) // SHOCK CAPTURING
{
norm_Rv = sqrt(pdeResidual_u*pdeResidual_u + pdeResidual_v*pdeResidual_v);// + pdeResidual_w*pdeResidual_w);
q_numDiff_u[eN_k] = C_dc*norm_Rv*(useMetrics/sqrt(G_dd_G+1.0e-12) +
(1.0-useMetrics)*hFactor*hFactor*elementDiameter[eN]*elementDiameter[eN]);
q_numDiff_v[eN_k] = q_numDiff_u[eN_k];
q_numDiff_w[eN_k] = q_numDiff_u[eN_k];
}
else // ARTIFICIAL_VISCOSITY==2; i.e, ENTROPY VISCOSITY
{
double rho = q_rho[eN_k];
double mu = q_rho[eN_k]*q_nu[eN_k];
double vel2 = u*u + v*v;
// entropy residual
double Res_in_x =
porosity*rho*((u-un)/dt + (u*grad_u[0]+v*grad_u[1]) - g[0])
+ (KILL_PRESSURE_TERM == 1 ? 0. : 1.)*grad_p[0]
- (MULTIPLY_EXTERNAL_FORCE_BY_DENSITY == 1 ? porosity*rho : 1.0)*forcex[eN_k]
- mu*(hess_u[0] + hess_u[3]) // u_xx + u_yy
- mu*(hess_u[0] + hess_v[2]); // u_xx + v_yx
double Res_in_y =
porosity*rho*((v-vn)/dt + (u*grad_v[0]+v*grad_v[1]) - g[1])
+ (KILL_PRESSURE_TERM == 1 ? 0. : 1.)*grad_p[1]
- (MULTIPLY_EXTERNAL_FORCE_BY_DENSITY == 1 ? porosity*rho : 1.0)*forcey[eN_k]
- mu*(hess_v[0] + hess_v[3]) // v_xx + v_yy
- mu*(hess_u[1] + hess_v[3]); // u_xy + v_yy
// compute entropy residual
double entRes_times_u = Res_in_x*u + Res_in_y*v;
double hK = elementDiameter[eN]/order_polynomial;
q_numDiff_u[eN_k] = fmin(cMax*porosity*rho*hK*std::sqrt(vel2),
cE*hK*hK*fabs(entRes_times_u)/(vel2+1E-10));
q_numDiff_v[eN_k] = q_numDiff_u[eN_k];
q_numDiff_w[eN_k] = q_numDiff_u[eN_k];
if (CELL_BASED_EV_COEFF)
{
linVisc_eN = fmax(porosity*rho*std::sqrt(vel2),linVisc_eN);
nlinVisc_eN_num = fmax(fabs(entRes_times_u),nlinVisc_eN_num);
nlinVisc_eN_den = fmax(vel2,nlinVisc_eN_den);
}
}
//
//update element residual
//
double mesh_vel[2];
mesh_vel[0] = xt;
mesh_vel[1] = yt;
// Save velocity and its gradient (to be used in other models and to compute errors)
q_velocity[eN_k_nSpace+0]=u;
q_velocity[eN_k_nSpace+1]=v;
/* q_velocity[eN_k_nSpace+2]=w; */
for (int I=0;I<nSpace;I++)
{
q_grad_u[eN_k_nSpace+I] = grad_u[I];
q_grad_v[eN_k_nSpace+I] = grad_v[I];
/* q_grad_w[eN_k_nSpace+I] = grad_w[I]; */
}
// save divergence of velocity
q_divU[eN_k] = q_grad_u[eN_k_nSpace+0] + q_grad_v[eN_k_nSpace+1];
// SURFACE TENSION //
double unit_normal[nSpace];
double norm_grad_phi = 0.;
for (int I=0;I<nSpace;I++)
norm_grad_phi += normal_phi[eN_k_nSpace+I]*normal_phi[eN_k_nSpace+I];
norm_grad_phi = std::sqrt(norm_grad_phi) + 1E-10;
for (int I=0;I<nSpace;I++)
unit_normal[I] = normal_phi[eN_k_nSpace+I]/norm_grad_phi;
// compute auxiliary vectors for explicit term of 2D surf tension
// v1 = [1-nx^2 -nx*ny]^T
double v1[nSpace];
v1[0]=1.-unit_normal[0]*unit_normal[0];
v1[1]=-unit_normal[0]*unit_normal[1];
// v2 = [-nx*ny 1-ny^2]^T
double v2[nSpace];
v2[0]=-unit_normal[0]*unit_normal[1];
v2[1]=1.-unit_normal[1]*unit_normal[1];
double delta = gf.D(eps_mu,phi[eN_k]); //use eps_rho instead?
register double vel_tgrad_test_i[nSpace], tgrad_u[nSpace], tgrad_v[nSpace];
calculateTangentialGradient(unit_normal,
grad_u,
tgrad_u);
calculateTangentialGradient(unit_normal,
grad_v,
tgrad_v);
// END OF SURFACE TENSION //
if (ARTIFICIAL_VISCOSITY==3 || ARTIFICIAL_VISCOSITY==4)
{
velStar[0] = q_velocity_sge[eN_k_nSpace+0];
velStar[1] = q_velocity_sge[eN_k_nSpace+1];
/*velStar[2] = q_velocity_sge[eN_k_nSpace+2];*/
}
for(int i=0;i<nDOF_test_element;i++)
{
register int i_nSpace=i*nSpace;
calculateTangentialGradient(unit_normal,
&vel_grad_trial[i_nSpace],
vel_tgrad_test_i);
phisErrorElement[i]+=std::abs(phisError[eN_k_nSpace+0])*p_test_dV[i];
/* std::cout<<"elemRes_mesh "<<mesh_vel[0]<<'\t'<<mesh_vel[2]<<'\t'<<p_test_dV[i]<<'\t'<<(q_dV_last[eN_k]/dV)<<'\t'<<dV<<std::endl; */
/* elementResidual_mesh[i] += ck.Reaction_weak(1.0,p_test_dV[i]) - */
/* ck.Reaction_weak(1.0,p_test_dV[i]*q_dV_last[eN_k]/dV) - */
/* ck.Advection_weak(mesh_vel,&p_grad_test_dV[i_nSpace]); */
/* elementResidual_p[i] += ck.Mass_weak(-q_dvos_dt[eN_k],p_test_dV[i]) + */
/* ck.Advection_weak(mass_adv,&p_grad_test_dV[i_nSpace]) + */
/* DM*MOVING_DOMAIN*(ck.Reaction_weak(alphaBDF*1.0,p_test_dV[i]) - */
/* ck.Reaction_weak(alphaBDF*1.0,p_test_dV[i]*q_dV_last[eN_k]/dV) - */
/* ck.Advection_weak(mesh_vel,&p_grad_test_dV[i_nSpace])) + */
/* //VRANS */
/* ck.Reaction_weak(mass_source,p_test_dV[i]) + //VRANS source term for wave maker */
/* // */
/* ck.SubgridError(subgridError_u,Lstar_u_p[i]) + */
/* ck.SubgridError(subgridError_v,Lstar_v_p[i]);// + */
/* /\* ck.SubgridError(subgridError_w,Lstar_w_p[i]); *\/ */
elementResidual_u[i] += // mql. CHECK.
ck.Mass_weak(mom_u_acc_t,vel_test_dV[i]) +
ck.Advection_weak(mom_u_adv,&vel_grad_test_dV[i_nSpace]) +
ck.Diffusion_weak(sdInfo_u_u_rowptr.data(),sdInfo_u_u_colind.data(),mom_uu_diff_ten,grad_u,&vel_grad_test_dV[i_nSpace]) +
ck.Diffusion_weak(sdInfo_u_v_rowptr.data(),sdInfo_u_v_colind.data(),mom_uv_diff_ten,grad_v,&vel_grad_test_dV[i_nSpace]) +
/* ck.Diffusion_weak(sdInfo_u_w_rowptr,sdInfo_u_w_colind,mom_uw_diff_ten,grad_w,&vel_grad_test_dV[i_nSpace]) + */
ck.Reaction_weak(mom_u_source,vel_test_dV[i]) +
ck.Hamiltonian_weak(mom_u_ham,vel_test_dV[i]) +
(INT_BY_PARTS_PRESSURE==1 ? -1.0*p*vel_grad_test_dV[i_nSpace+0] : 0.) +
//ck.SubgridError(subgridError_p,Lstar_p_u[i]) +
USE_SUPG*ck.SubgridError(subgridError_u,Lstar_u_u[i]) +
ck.NumericalDiffusion(q_numDiff_u_last[eN_k],grad_u,&vel_grad_test_dV[i_nSpace]) +
//surface tension
ck.NumericalDiffusion(delta*sigma*dV,v1,vel_tgrad_test_i) + //exp.
ck.NumericalDiffusion(dt*delta*sigma*dV,tgrad_u,vel_tgrad_test_i); //imp.
mom_u_source_i[i] += ck.Reaction_weak(mom_u_source,vel_test_dV[i]);
betaDrag_i[i] += ck.Reaction_weak(dmom_u_source[0],
vel_test_dV[i]);
vos_i[i] += ck.Reaction_weak(1.0-porosity,
vel_test_dV[i]);
elementResidual_v[i] +=
ck.Mass_weak(mom_v_acc_t,vel_test_dV[i]) +
ck.Advection_weak(mom_v_adv,&vel_grad_test_dV[i_nSpace]) +
ck.Diffusion_weak(sdInfo_v_u_rowptr.data(),sdInfo_v_u_colind.data(),mom_vu_diff_ten,grad_u,&vel_grad_test_dV[i_nSpace]) +
ck.Diffusion_weak(sdInfo_v_v_rowptr.data(),sdInfo_v_v_colind.data(),mom_vv_diff_ten,grad_v,&vel_grad_test_dV[i_nSpace]) +
/* ck.Diffusion_weak(sdInfo_v_w_rowptr,sdInfo_v_w_colind,mom_vw_diff_ten,grad_w,&vel_grad_test_dV[i_nSpace]) + */
ck.Reaction_weak(mom_v_source,vel_test_dV[i]) +
ck.Hamiltonian_weak(mom_v_ham,vel_test_dV[i]) +
(INT_BY_PARTS_PRESSURE==1 ? -1.0*p*vel_grad_test_dV[i_nSpace+1] : 0.) +
//ck.SubgridError(subgridError_p,Lstar_p_v[i]) +
USE_SUPG*ck.SubgridError(subgridError_v,Lstar_v_v[i]) +
ck.NumericalDiffusion(q_numDiff_v_last[eN_k],grad_v,&vel_grad_test_dV[i_nSpace]) +
//surface tension
ck.NumericalDiffusion(delta*sigma*dV,v2,vel_tgrad_test_i) + //exp.
ck.NumericalDiffusion(dt*delta*sigma*dV,tgrad_v,vel_tgrad_test_i); //imp.
mom_v_source_i[i] += ck.Reaction_weak(mom_v_source,vel_test_dV[i]);
/* elementResidual_w[i] +=
ck.Mass_weak(mom_w_acc_t,vel_test_dV[i]) + */
/* ck.Advection_weak(mom_w_adv,&vel_grad_test_dV[i_nSpace]) + */
/* ck.Diffusion_weak(sdInfo_w_u_rowptr,sdInfo_w_u_colind,mom_wu_diff_ten,grad_u,&vel_grad_test_dV[i_nSpace]) + */
/* ck.Diffusion_weak(sdInfo_w_v_rowptr,sdInfo_w_v_colind,mom_wv_diff_ten,grad_v,&vel_grad_test_dV[i_nSpace]) + */
/* ck.Diffusion_weak(sdInfo_w_w_rowptr,sdInfo_w_w_colind,mom_ww_diff_ten,grad_w,&vel_grad_test_dV[i_nSpace]) + */
/* ck.Reaction_weak(mom_w_source,vel_test_dV[i]) + */
/* ck.Hamiltonian_weak(mom_w_ham,vel_test_dV[i]) + */
/* (INT_BY_PARTS_PRESSURE==1 ? -1.0*p*vel_grad_test_dV[i_nSpace+2] : 0.) + */
/* ck.SubgridError(subgridError_p,Lstar_p_w[i]) + */
/* ck.SubgridError(subgridError_w,Lstar_w_w[i]) + */
/* ck.NumericalDiffusion(q_numDiff_w_last[eN_k],grad_w,&vel_grad_test_dV[i_nSpace]); */
if (ARTIFICIAL_VISCOSITY==4)
{
// ***** COMPUTE ENTROPY RESIDUAL ***** //
// mql. NOTE that the test functions are weighted by the velocity
elementEntropyResidual[i] +=
// x-component
ck.Mass_weak(mom_u_acc_t,u*vel_test_dV[i]) + // time derivative
ck.Advection_weak(mom_u_adv,&u_times_vel_grad_test_dV[i_nSpace])+//m.mesh
ck.Diffusion_weak(sdInfo_u_u_rowptr.data(),
sdInfo_u_u_colind.data(),
mom_uu_diff_ten,
grad_u,
&u_times_vel_grad_test_dV[i_nSpace]) +
ck.Diffusion_weak(sdInfo_u_v_rowptr.data(),
sdInfo_u_v_colind.data(),
mom_uv_diff_ten,
grad_v,
&u_times_vel_grad_test_dV[i_nSpace]) +
ck.Reaction_weak(mom_u_source,u*vel_test_dV[i]) + // Force term
ck.Hamiltonian_weak(mom_u_ham,u*vel_test_dV[i]) // Pres + Non-linearity
+ // y-component
ck.Mass_weak(mom_v_acc_t,v*vel_test_dV[i]) + // time derivative
ck.Advection_weak(mom_v_adv,&v_times_vel_grad_test_dV[i_nSpace])+//m.mesh
ck.Diffusion_weak(sdInfo_v_u_rowptr.data(),
sdInfo_v_u_colind.data(),
mom_vu_diff_ten,
grad_u,
&v_times_vel_grad_test_dV[i_nSpace])+
ck.Diffusion_weak(sdInfo_v_v_rowptr.data(),
sdInfo_v_v_colind.data(),
mom_vv_diff_ten,
grad_v,
&v_times_vel_grad_test_dV[i_nSpace])+
ck.Reaction_weak(mom_v_source,v*vel_test_dV[i]) + // force term
ck.Hamiltonian_weak(mom_v_ham,v*vel_test_dV[i]); // Pres + Non-linearity
}
if (ARTIFICIAL_VISCOSITY==3 || ARTIFICIAL_VISCOSITY==4)
{
for(int j=0;j<nDOF_trial_element;j++)
{
int j_nSpace = j*nSpace;
int i_nSpace = i*nSpace;
elementTransport[i][j] += // int[rho*(velStar.grad_wj)*wi*dx]
q_rho[eN_k]*porosity*
ck.AdvectionJacobian_strong(velStar,
&vel_grad_test_dV[j_nSpace])
*vel_trial_ref[k*nDOF_trial_element+i];
elementTransposeTransport[i][j] += // int[rho*(velStar.grad_wi)*wj*dx]
q_rho[eN_k]*porosity*
ck.AdvectionJacobian_strong(velStar,
&vel_grad_test_dV[i_nSpace])
*vel_trial_ref[k*nDOF_trial_element+j];
}
}//j
}//i
}
element_uStar_He[eN] = det_hess_uStar_Ke/area_Ke;
element_vStar_He[eN] = det_hess_vStar_Ke/area_Ke;
// End computation of cell based EV coeff //
if (CELL_BASED_EV_COEFF && ARTIFICIAL_VISCOSITY==2)
{
double hK = elementDiameter[eN];
double artVisc = fmin(cMax*hK*linVisc_eN,
cE*hK*hK*nlinVisc_eN_num/(nlinVisc_eN_den+1E-10));
for(int k=0;k<nQuadraturePoints_element;k++)
{
register int eN_k = eN*nQuadraturePoints_element+k;
q_numDiff_u[eN_k] = artVisc;
q_numDiff_v[eN_k] = artVisc;
q_numDiff_w[eN_k] = artVisc;
}
}
//
//load element into global residual and save element residual
//
for(int i=0;i<nDOF_test_element;i++)
{
register int eN_i=eN*nDOF_test_element+i;
phisErrorNodal[vel_l2g[eN_i]]+= element_active*phisErrorElement[i];
/* elementResidual_p_save[eN_i] += elementResidual_p[i]; */
/* mesh_volume_conservation_element_weak += elementResidual_mesh[i]; */
/* globalResidual[offset_p+stride_p*p_l2g[eN_i]]+=elementResidual_p[i]; */
globalResidual[offset_u+stride_u*vel_l2g[eN_i]]+=element_active*elementResidual_u[i];
globalResidual[offset_v+stride_v*vel_l2g[eN_i]]+=element_active*elementResidual_v[i];
/* globalResidual[offset_w+stride_w*vel_l2g[eN_i]]+=elementResidual_w[i]; */
ncDrag[offset_u+stride_u*vel_l2g[eN_i]]+=mom_u_source_i[i];
ncDrag[offset_v+stride_v*vel_l2g[eN_i]]+=mom_v_source_i[i];
betaDrag[vel_l2g[eN_i]] += betaDrag_i[i];
vos_vel_nodes[vel_l2g[eN_i]] += vos_i[i];
// compute numerator and denominator of uStar_hi and vStar_hi
if (ARTIFICIAL_VISCOSITY==3)
{
uStar_hi[vel_l2g[eN_i]] += element_uStar_He[eN]; // offset=0, stride=1 since this is per component of the equation
vStar_hi[vel_l2g[eN_i]] += element_vStar_He[eN];
den_hi[vel_l2g[eN_i]] += 1;
}
if (ARTIFICIAL_VISCOSITY==4)
{
// DISTRIBUTE ENTROPY RESIDUAL //
entropyResidualPerNode[vel_l2g[eN_i]] += elementEntropyResidual[i];
}
if (ARTIFICIAL_VISCOSITY==3 || ARTIFICIAL_VISCOSITY==4)
{
for (int j=0;j<nDOF_trial_element;j++)
{
int eN_i_j = eN_i*nDOF_trial_element+j;
TransportMatrix[csrRowIndeces_1D[eN_i]
+ csrColumnOffsets_1D[eN_i_j]]
+= elementTransport[i][j];
// transpose
TransposeTransportMatrix[csrRowIndeces_1D[eN_i]
+ csrColumnOffsets_1D[eN_i_j]]
+= elementTransposeTransport[i][j];
}//j
}
}//i
/* mesh_volume_conservation += mesh_volume_conservation_element; */
/* mesh_volume_conservation_weak += mesh_volume_conservation_element_weak; */
/* mesh_volume_conservation_err_max=fmax(mesh_volume_conservation_err_max,fabs(mesh_volume_conservation_element)); */
/* mesh_volume_conservation_err_max_weak=fmax(mesh_volume_conservation_err_max_weak,fabs(mesh_volume_conservation_element_weak)); */
}//elements
if(CUT_CELL_INTEGRATION > 0)
std::cout<<std::flush;
// loop in DOFs for discrete upwinding
if (ARTIFICIAL_VISCOSITY==3 || ARTIFICIAL_VISCOSITY==4)
{
// FIRST LOOP ON DOFs //
for (int i=0; i<numDOFs_1D; i++)
{
if (ARTIFICIAL_VISCOSITY==4) // via entropy viscosity
{
// normalize entropy residual per node
double max_u2i = (std::pow(u_dof[i],2.) +
std::pow(v_dof[i],2.));
double min_u2i = max_u2i;
for (int offset=rowptr_1D[i]; offset<rowptr_1D[i+1]; offset++)
{
int j = colind_1D[offset];
double u2j = (std::pow(u_dof[j],2.) +
std::pow(v_dof[j],2.));
max_u2i = fmax(max_u2i,u2j);
min_u2i = fmin(min_u2i,u2j);
}
double normi = 0.5*(max_u2i + min_u2i) + 1E-10;
entropyResidualPerNode[i] = fabs(entropyResidualPerNode[i])/normi;
}
else // via smoothness indicator
{
// computation of beta
double uStari = uStar_dof[i];
double vStari = vStar_dof[i];
double u_beta_numerator = 0., u_beta_denominator = 0.;
double v_beta_numerator = 0., v_beta_denominator = 0.;
// loop on sparsity pattern
for (int offset=rowptr_1D[i]; offset<rowptr_1D[i+1]; offset++)
{
int j = colind_1D[offset];
double uStarj = uStar_dof[j];
double vStarj = vStar_dof[j];
// for u component
u_beta_numerator += (uStarj - uStari);
u_beta_denominator += fabs(uStarj - uStari);
// for v component
v_beta_numerator += (vStarj - vStari);
v_beta_denominator += fabs(vStarj - vStari);
}
double u_beta = fabs(u_beta_numerator)/(u_beta_denominator+1E-10);
double v_beta = fabs(v_beta_numerator)/(v_beta_denominator+1E-10);
// compute psi=beta^power
if (ANISOTROPIC_DIFFUSION==1)
{
uStar_psi[i] = (POWER_SMOOTHNESS_INDICATOR==0 ? 1.0 : std::pow(u_beta, POWER_SMOOTHNESS_INDICATOR));
vStar_psi[i] = (POWER_SMOOTHNESS_INDICATOR==0 ? 1.0 : std::pow(v_beta, POWER_SMOOTHNESS_INDICATOR));
}
else // ISOTROPIC ARTIFICIAL DIFFUSION
{
double psi = (POWER_SMOOTHNESS_INDICATOR==0 ? 1.0 : std::pow(fmax(u_beta,v_beta), POWER_SMOOTHNESS_INDICATOR));
uStar_psi[i] = psi;
vStar_psi[i] = psi;
}
// for computation of gamma
uStar_hi[i] /= den_hi[i];
vStar_hi[i] /= den_hi[i];
}
}
if (ARTIFICIAL_VISCOSITY==3)
{
for(int eN=0;eN<nElements_global;eN++)
{
double uStar_He = element_uStar_He[eN];
double vStar_He = element_vStar_He[eN];
for(int i=0;i<nDOF_test_element;i++)
{
register int eN_i=eN*nDOF_test_element+i;
register int gi = vel_l2g[eN_i]; // offset=0, stride=1
uStar_min_hiHe[gi] = fmin(uStar_min_hiHe[gi], uStar_hi[gi]*uStar_He);
vStar_min_hiHe[gi] = fmin(vStar_min_hiHe[gi], vStar_hi[gi]*vStar_He);
}
}
}
// EXTRA LOOP ON DOFs to COMPUTE GAMMA INDICATOR//
if (ARTIFICIAL_VISCOSITY==3)
{
for (int i=0; i<numDOFs_1D; i++)
{
// for gamma indicator
double uStar_hi2 = uStar_hi[i]*uStar_hi[i];
double vStar_hi2 = vStar_hi[i]*vStar_hi[i];
if (isBoundary_1D[i] == 1)
{
uStar_gamma[i] = 1; // set gamma=1 since at boundary we don't have enough information
vStar_gamma[i] = 1;
}
else
{
if (ANISOTROPIC_DIFFUSION==1)
{
uStar_gamma[i] = 1.-fmax(0, fmin(uStar_hi2, C_FOR_GAMMA_INDICATOR*uStar_min_hiHe[i]))/(uStar_hi2+EPS_FOR_GAMMA_INDICATOR);
vStar_gamma[i] = 1.-fmax(0, fmin(vStar_hi2, C_FOR_GAMMA_INDICATOR*vStar_min_hiHe[i]))/(vStar_hi2+EPS_FOR_GAMMA_INDICATOR);
}
else // ISOTROPIC ARTIFICIAL DIFFUSION
{
double gamma = fmax(1.-fmax(0, fmin(uStar_hi2, C_FOR_GAMMA_INDICATOR*uStar_min_hiHe[i]))/(uStar_hi2+EPS_FOR_GAMMA_INDICATOR),
1.-fmax(0, fmin(vStar_hi2, C_FOR_GAMMA_INDICATOR*vStar_min_hiHe[i]))/(vStar_hi2+EPS_FOR_GAMMA_INDICATOR));
uStar_gamma[i] = gamma;
vStar_gamma[i] = gamma;
}
}
}
}
// SECOND LOOP ON DOFs //
int ij=0;
for (int i=0; i<numDOFs_1D; i++)
{
int ii;
double uStar_dii = 0;
double vStar_dii = 0;
double ui = u_dof[i];
double vi = v_dof[i];
double ith_u_dissipative_term = 0;
double ith_v_dissipative_term = 0;
double uStar_alphai = USE_GAMMA_INDICATOR==1 ? fmin(uStar_psi[i], uStar_gamma[i]) : uStar_psi[i];
double vStar_alphai = USE_GAMMA_INDICATOR==1 ? fmin(vStar_psi[i], vStar_gamma[i]) : vStar_psi[i];
for (int offset=rowptr_1D[i]; offset<rowptr_1D[i+1]; offset++)
{
int j = colind_1D[offset];
if (i!=j)
{
double uj = u_dof[j];
double vj = v_dof[j];
double uStar_alphaj = USE_GAMMA_INDICATOR==1 ? fmin(uStar_psi[j], uStar_gamma[j]) : uStar_psi[j];
double vStar_alphaj = USE_GAMMA_INDICATOR==1 ? fmin(vStar_psi[j], vStar_gamma[j]) : vStar_psi[j];
if (ARTIFICIAL_VISCOSITY==4) // via entropy viscosity
{
double dEVij = fmax(laggedEntropyResidualPerNode[i],
laggedEntropyResidualPerNode[j]);
double dLij = fmax(0.,fmax(TransportMatrix[ij],
TransposeTransportMatrix[ij]));
uStar_dMatrix[ij] = fmin(dLij,cE*dEVij);
vStar_dMatrix[i] = uStar_dMatrix[ij];
}
else // via smoothness indicator
{
uStar_dMatrix[ij] = fmax(0.,fmax(uStar_alphai*TransportMatrix[ij], // by S. Badia
uStar_alphaj*TransposeTransportMatrix[ij]));
vStar_dMatrix[ij] = fmax(0.,fmax(vStar_alphai*TransportMatrix[ij], // by S. Badia
vStar_alphaj*TransposeTransportMatrix[ij]));
}
uStar_dii -= uStar_dMatrix[ij];
vStar_dii -= vStar_dMatrix[ij];
//dissipative terms
ith_u_dissipative_term += uStar_dMatrix[ij]*(uj-ui);
ith_v_dissipative_term += vStar_dMatrix[ij]*(vj-vi);
}
else
{
ii = ij;
}
// update ij
ij++;
}
uStar_dMatrix[ii] = uStar_dii;
vStar_dMatrix[ii] = vStar_dii;
globalResidual[offset_u+stride_u*i] += -ith_u_dissipative_term;
globalResidual[offset_v+stride_v*i] += -ith_v_dissipative_term;
}
}
//
//loop over the surrogate boundaries in SB method and assembly into residual
//
if(USE_SBM>0)
{
if(USE_SBM==1)
{
std::memset(particle_netForces.data(),0,nParticles*3*sizeof(double));
std::memset(particle_netMoments.data(),0,nParticles*3*sizeof(double));
}
for (int ebN_s=0;ebN_s < surrogate_boundaries.size();ebN_s++)
{
// Initialization of the force to 0
register double Fx = 0.0, Fy = 0.0, Fxp = 0.0, Fyp = 0.0, surfaceArea=0.0, Mz = 0.0;
register int ebN = surrogate_boundaries[ebN_s],
eN = elementBoundaryElementsArray[ebN*2+surrogate_boundary_elements[ebN_s]],
ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+surrogate_boundary_elements[ebN_s]],
eN_nDOF_trial_element = eN*nDOF_trial_element;
register double elementResidual_mesh[nDOF_test_element],
elementResidual_p[nDOF_test_element],
elementResidual_u[nDOF_test_element],
elementResidual_v[nDOF_test_element],
//elementResidual_w[nDOF_test_element],
eps_rho,eps_mu;
//This assumption is wrong for parallel: If one of nodes of this edge is owned by this processor,
//then the integral over this edge has contribution to the residual and Jacobian.
//if (ebN >= nElementBoundaries_owned) continue;
//std::cout<<"Surrogate edge "<<ebN<<" element neighbor "<<eN<<" local element boundary "<<ebN_local<<std::endl;
for (int i=0;i<nDOF_test_element;i++)
{
elementResidual_mesh[i]=0.0;
elementResidual_p[i]=0.0;
elementResidual_u[i]=0.0;
elementResidual_v[i]=0.0;
/* elementResidual_w[i]=0.0; */
}
for (int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
{
register int ebN_kb = ebN*nQuadraturePoints_elementBoundary+kb,
/* ebNE_kb_nSpace = ebNE_kb*nSpace, */
ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
ebN_local_kb_nSpace = ebN_local_kb*nSpace;
register double
u_ext=0.0,
v_ext=0.0,
bc_u_ext=0.0,
bc_v_ext=0.0,
grad_u_ext[nSpace],
grad_v_ext[nSpace],
jac_ext[nSpace*nSpace],
jacDet_ext,
jacInv_ext[nSpace*nSpace],
boundaryJac[nSpace*(nSpace-1)],
metricTensor[(nSpace-1)*(nSpace-1)],
metricTensorDetSqrt,
dS,p_test_dS[nDOF_test_element],vel_test_dS[nDOF_test_element],
p_grad_trial_trace[nDOF_trial_element*nSpace],vel_grad_trial_trace[nDOF_trial_element*nSpace],
vel_grad_test_dS[nDOF_trial_element*nSpace],
normal[2],x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
G[nSpace*nSpace],G_dd_G,tr_G,h_phi,h_penalty,penalty,
force_x,force_y,force_z,force_p_x,force_p_y,force_p_z,force_v_x,force_v_y,force_v_z,r_x,r_y,r_z;
//compute information about mapping from reference element to physical element
ck.calculateMapping_elementBoundary(eN,
ebN_local,
kb,
ebN_local_kb,
mesh_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
mesh_grad_trial_trace_ref.data(),
boundaryJac_ref.data(),
jac_ext,
jacDet_ext,
jacInv_ext,
boundaryJac,
metricTensor,
metricTensorDetSqrt,
normal_ref.data(),
normal,
x_ext,y_ext,z_ext);
ck.calculateMappingVelocity_elementBoundary(eN,
ebN_local,
kb,
ebN_local_kb,
mesh_velocity_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
xt_ext,yt_ext,zt_ext,
normal,
boundaryJac,
metricTensor,
integralScaling);
dS = metricTensorDetSqrt*dS_ref[kb];
//get the metric tensor
ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
//compute shape and solution information
//shape
ck.gradTrialFromRef(&vel_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,vel_grad_trial_trace);
//solution and gradients
ck.valFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext);
ck.valFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],v_ext);
ck.gradFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_u_ext);
ck.gradFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_v_ext);
//precalculate test function products with integration weights
for (int j=0;j<nDOF_trial_element;j++)
{
vel_test_dS[j] = vel_test_trace_ref[ebN_local_kb*nDOF_test_element+j]*dS;
for (int I=0;I<nSpace;I++)
vel_grad_test_dS[j*nSpace+I] = vel_grad_trial_trace[j*nSpace+I]*dS;//cek hack, using trial
}
double dist = 0.0;
double distance[2], P_normal[2], P_tangent[2]; // distance vector, normal and tangent of the physical boundary
if(use_ball_as_particle==1)
{
get_distance_to_ball(nParticles,ball_center.data(),ball_radius.data(),
x_ext,y_ext,z_ext,
dist);
get_normal_to_ith_ball(nParticles,ball_center.data(),ball_radius.data(),
surrogate_boundary_particle[ebN_s],
x_ext,y_ext,z_ext,
P_normal[0],P_normal[1]);
get_velocity_to_ith_ball(nParticles,ball_center.data(),ball_radius.data(),
ball_velocity.data(),ball_angular_velocity.data(),
surrogate_boundary_particle[ebN_s],
x_ext-dist*P_normal[0],//corresponding point on the boundary of the particle
y_ext-dist*P_normal[1],
0.0,//z_ext,
bc_u_ext,bc_v_ext);
}
else
{
dist = ebq_global_phi_solid[ebN_kb];
P_normal[0] = ebq_global_grad_phi_solid[ebN_kb*3+0];
P_normal[1] = ebq_global_grad_phi_solid[ebN_kb*3+1];
bc_u_ext = ebq_particle_velocity_solid [ebN_kb*3+0];
bc_v_ext = ebq_particle_velocity_solid [ebN_kb*3+1];
}
ck.calculateGScale(G,normal,h_penalty);
//
//update the element and global residual storage
//
assert(h_penalty>0.0);
if (h_penalty < std::abs(dist))
h_penalty = std::abs(dist);
distance[0] = -P_normal[0]*dist;//distance=vector from \tilde{x} to x. It holds also when dist<0.0
distance[1] = -P_normal[1]*dist;
P_tangent[0] = -P_normal[1];
P_tangent[1] = P_normal[0];
double visco = nu_0*rho_0;
double C_adim = C_sbm*visco/h_penalty;
double beta_adim = beta_sbm*visco/h_penalty;
const double grad_u_d[2] = {get_dot_product(distance,grad_u_ext),
get_dot_product(distance,grad_v_ext)};
double res[2];
const double u_m_uD[2] = {u_ext - bc_u_ext,v_ext - bc_v_ext};
const double zero_vec[2]={0.,0.};
const double grad_u_t[2] = {get_dot_product(P_tangent,grad_u_ext),
get_dot_product(P_tangent,grad_v_ext)};
for (int i=0;i<nDOF_test_element;i++)
{
int eN_i = eN*nDOF_test_element+i;
int GlobPos_u = offset_u+stride_u*vel_l2g[eN_i];
int GlobPos_v = offset_v+stride_v*vel_l2g[eN_i];
double phi_i = vel_test_dS[i];
double Gxphi_i = vel_grad_test_dS[i*nSpace+0];
double Gyphi_i = vel_grad_test_dS[i*nSpace+1];
double *grad_phi_i = &vel_grad_test_dS[i*nSpace+0];
const double grad_phi_i_dot_d = get_dot_product(distance,grad_phi_i);
const double grad_phi_i_dot_t = get_dot_product(P_tangent,grad_phi_i);
// (1)
globalResidual[GlobPos_u] += C_adim*phi_i*u_m_uD[0];
globalResidual[GlobPos_v] += C_adim*phi_i*u_m_uD[1];
Fx += C_adim*phi_i*u_m_uD[0];
Fy += C_adim*phi_i*u_m_uD[1];
// (2)
get_symmetric_gradient_dot_vec(grad_u_ext,grad_v_ext,normal,res);//Use normal for consistency
globalResidual[GlobPos_u] -= visco * phi_i*res[0];
globalResidual[GlobPos_v] -= visco * phi_i*res[1];
Fx -= visco * phi_i*res[0];
Fy -= visco * phi_i*res[1];
// (3)
get_symmetric_gradient_dot_vec(grad_phi_i,zero_vec,normal,res);
globalResidual[GlobPos_u] -= visco * get_dot_product(u_m_uD,res);//Use normal for consistency
get_symmetric_gradient_dot_vec(zero_vec,grad_phi_i,normal,res);
globalResidual[GlobPos_v] -= visco * get_dot_product(u_m_uD,res);//Use normal for consistency
get_symmetric_gradient_dot_vec(grad_phi_i,zero_vec,normal,res);
Fx -= visco * get_dot_product(u_m_uD,res);//Use normal for consistency
get_symmetric_gradient_dot_vec(zero_vec,grad_phi_i,normal,res);
Fy -= visco * get_dot_product(u_m_uD,res);//Use normal for consistency
// (4)
globalResidual[GlobPos_u] += C_adim*grad_phi_i_dot_d*u_m_uD[0];
globalResidual[GlobPos_v] += C_adim*grad_phi_i_dot_d*u_m_uD[1];
Fx += C_adim*grad_phi_i_dot_d*u_m_uD[0];
Fy += C_adim*grad_phi_i_dot_d*u_m_uD[1];
// (5)
globalResidual[GlobPos_u] += C_adim*grad_phi_i_dot_d*grad_u_d[0];
globalResidual[GlobPos_v] += C_adim*grad_phi_i_dot_d*grad_u_d[1];
Fx += C_adim*grad_phi_i_dot_d*grad_u_d[0];
Fy += C_adim*grad_phi_i_dot_d*grad_u_d[1];
// (6)
globalResidual[GlobPos_u] += C_adim*phi_i*grad_u_d[0];
globalResidual[GlobPos_v] += C_adim*phi_i*grad_u_d[1];
Fx += C_adim*phi_i*grad_u_d[0];
Fy += C_adim*phi_i*grad_u_d[1];
// (7)
get_symmetric_gradient_dot_vec(grad_phi_i,zero_vec,normal,res);//Use normal for consistency
globalResidual[GlobPos_u] -= visco*get_dot_product(grad_u_d,res);
get_symmetric_gradient_dot_vec(zero_vec,grad_phi_i,normal,res);//Use normal for consistency
globalResidual[GlobPos_v] -= visco*get_dot_product(grad_u_d,res);
get_symmetric_gradient_dot_vec(grad_phi_i,zero_vec,normal,res);//Use normal for consistency
Fx -= visco*get_dot_product(grad_u_d,res);
get_symmetric_gradient_dot_vec(zero_vec,grad_phi_i,normal,res);//Use normal for consistency
Fy -= visco*get_dot_product(grad_u_d,res);
//the penalization on the tangential derivative
//B < Gw t , (Gu - GuD) t >
globalResidual[GlobPos_u] += beta_adim*grad_u_t[0]*grad_phi_i_dot_t;
globalResidual[GlobPos_v] += beta_adim*grad_u_t[1]*grad_phi_i_dot_t;
Fx += beta_adim*grad_u_t[0]*grad_phi_i_dot_t;
Fy += beta_adim*grad_u_t[1]*grad_phi_i_dot_t;
}//i
//
// Forces
//
//compute pressure at the quadrature point of the edge from dof-value of the pressure
double p_ext = 0.0;
for (int i=0; i<nDOF_per_element_pressure;++i)
{
p_ext += p_dof[p_l2g[eN*nDOF_per_element_pressure+i]]*p_trial_trace_ref[ebN_local_kb*nDOF_per_element_pressure+i];
}
double nx = P_normal[0]; //YY: normal direction outward of the solid.
double ny = P_normal[1];
Fx -= p_ext*nx*dS;
Fy -= p_ext*ny*dS;
Fxp -= p_ext*nx*dS;
Fyp -= p_ext*ny*dS;
surfaceArea += dS;
if(use_ball_as_particle==1)
{
r_x = x_ext - ball_center[surrogate_boundary_particle[ebN_s] * 3 + 0];
r_y = y_ext - ball_center[surrogate_boundary_particle[ebN_s] * 3 + 1];
}
else
{
r_x = x_ext - particle_centroids[surrogate_boundary_particle[ebN_s] * 3 + 0];
r_y = y_ext - particle_centroids[surrogate_boundary_particle[ebN_s] * 3 + 1];
}
Mz += r_x*Fy-r_y*Fx;
}//kb
if(USE_SBM==1
&& ebN < nElementBoundaries_owned)//avoid double counting
{
particle_surfaceArea[surrogate_boundary_particle[ebN_s]] += surfaceArea;
particle_netForces[3*surrogate_boundary_particle[ebN_s]+0] += Fx;
particle_netForces[3*surrogate_boundary_particle[ebN_s]+1] += Fy;
particle_netForces[3*( nParticles+surrogate_boundary_particle[ebN_s])+0] += Fxp;
particle_netForces[3*(2*nParticles+surrogate_boundary_particle[ebN_s])+0] += (Fx-Fxp);
particle_netForces[3*( nParticles+surrogate_boundary_particle[ebN_s])+1] += Fyp;
particle_netForces[3*(2*nParticles+surrogate_boundary_particle[ebN_s])+1] += (Fy-Fyp);
particle_netMoments[3*surrogate_boundary_particle[ebN_s]+2]+= Mz;
}
}//ebN_s
//std::cout<<" sbm force over surrogate boundary is: "<<Fx<<"\t"<<Fy<<std::endl;
//
}
//loop over exterior element boundaries to calculate surface integrals and load into element and global residuals
//
//ebNE is the Exterior element boundary INdex
//ebN is the element boundary INdex
//eN is the element index
gf.useExact=false;
gf_s.useExact=false;
for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
{
register int ebN = exteriorElementBoundariesArray[ebNE],
eN = elementBoundaryElementsArray[ebN*2+0],
ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0],
eN_nDOF_trial_element = eN*nDOF_trial_element;
register double elementResidual_mesh[nDOF_test_element],
elementResidual_p[nDOF_test_element],
elementResidual_u[nDOF_test_element],
elementResidual_v[nDOF_test_element],
//elementResidual_w[nDOF_test_element],
eps_rho,eps_mu;
const double* elementResidual_w(NULL);
for (int i=0;i<nDOF_test_element;i++)
{
elementResidual_mesh[i]=0.0;
elementResidual_p[i]=0.0;
elementResidual_u[i]=0.0;
elementResidual_v[i]=0.0;
/* elementResidual_w[i]=0.0; */
}
for (int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
{
register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
ebNE_kb_nSpace = ebNE_kb*nSpace,
ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
ebN_local_kb_nSpace = ebN_local_kb*nSpace;
register double p_ext=0.0,
u_ext=0.0,
v_ext=0.0,
w_ext=0.0,
grad_p_ext[nSpace],
grad_u_ext[nSpace],
grad_v_ext[nSpace],
grad_w_ext[nSpace],
mom_u_acc_ext=0.0,
dmom_u_acc_u_ext=0.0,
mom_v_acc_ext=0.0,
dmom_v_acc_v_ext=0.0,
mom_w_acc_ext=0.0,
dmom_w_acc_w_ext=0.0,
mass_adv_ext[nSpace],
dmass_adv_u_ext[nSpace],
dmass_adv_v_ext[nSpace],
dmass_adv_w_ext[nSpace],
mom_u_adv_ext[nSpace],
dmom_u_adv_u_ext[nSpace],
dmom_u_adv_v_ext[nSpace],
dmom_u_adv_w_ext[nSpace],
mom_v_adv_ext[nSpace],
dmom_v_adv_u_ext[nSpace],
dmom_v_adv_v_ext[nSpace],
dmom_v_adv_w_ext[nSpace],
mom_w_adv_ext[nSpace],
dmom_w_adv_u_ext[nSpace],
dmom_w_adv_v_ext[nSpace],
dmom_w_adv_w_ext[nSpace],
mom_uu_diff_ten_ext[nSpace],
mom_vv_diff_ten_ext[nSpace],
mom_ww_diff_ten_ext[nSpace],
mom_uv_diff_ten_ext[1],
mom_uw_diff_ten_ext[1],
mom_vu_diff_ten_ext[1],
mom_vw_diff_ten_ext[1],
mom_wu_diff_ten_ext[1],
mom_wv_diff_ten_ext[1],
mom_u_source_ext=0.0,
mom_v_source_ext=0.0,
mom_w_source_ext=0.0,
mom_u_ham_ext=0.0,
dmom_u_ham_grad_p_ext[nSpace],
dmom_u_ham_grad_u_ext[nSpace],
mom_v_ham_ext=0.0,
dmom_v_ham_grad_p_ext[nSpace],
dmom_v_ham_grad_v_ext[nSpace],
mom_w_ham_ext=0.0,
dmom_w_ham_grad_p_ext[nSpace],
dmom_w_ham_grad_w_ext[nSpace],
dmom_u_adv_p_ext[nSpace],
dmom_v_adv_p_ext[nSpace],
dmom_w_adv_p_ext[nSpace],
flux_mass_ext=0.0,
flux_mom_u_adv_ext=0.0,
flux_mom_v_adv_ext=0.0,
flux_mom_w_adv_ext=0.0,
flux_mom_uu_diff_ext=0.0,
flux_mom_uv_diff_ext=0.0,
flux_mom_uw_diff_ext=0.0,
flux_mom_vu_diff_ext=0.0,
flux_mom_vv_diff_ext=0.0,
flux_mom_vw_diff_ext=0.0,
flux_mom_wu_diff_ext=0.0,
flux_mom_wv_diff_ext=0.0,
flux_mom_ww_diff_ext=0.0,
bc_p_ext=0.0,
bc_u_ext=0.0,
bc_v_ext=0.0,
bc_w_ext=0.0,
bc_mom_u_acc_ext=0.0,
bc_dmom_u_acc_u_ext=0.0,
bc_mom_v_acc_ext=0.0,
bc_dmom_v_acc_v_ext=0.0,
bc_mom_w_acc_ext=0.0,
bc_dmom_w_acc_w_ext=0.0,
bc_mass_adv_ext[nSpace],
bc_dmass_adv_u_ext[nSpace],
bc_dmass_adv_v_ext[nSpace],
bc_dmass_adv_w_ext[nSpace],
bc_mom_u_adv_ext[nSpace],
bc_dmom_u_adv_u_ext[nSpace],
bc_dmom_u_adv_v_ext[nSpace],
bc_dmom_u_adv_w_ext[nSpace],
bc_mom_v_adv_ext[nSpace],
bc_dmom_v_adv_u_ext[nSpace],
bc_dmom_v_adv_v_ext[nSpace],
bc_dmom_v_adv_w_ext[nSpace],
bc_mom_w_adv_ext[nSpace],
bc_dmom_w_adv_u_ext[nSpace],
bc_dmom_w_adv_v_ext[nSpace],
bc_dmom_w_adv_w_ext[nSpace],
bc_mom_uu_diff_ten_ext[nSpace],
bc_mom_vv_diff_ten_ext[nSpace],
bc_mom_ww_diff_ten_ext[nSpace],
bc_mom_uv_diff_ten_ext[1],
bc_mom_uw_diff_ten_ext[1],
bc_mom_vu_diff_ten_ext[1],
bc_mom_vw_diff_ten_ext[1],
bc_mom_wu_diff_ten_ext[1],
bc_mom_wv_diff_ten_ext[1],
bc_mom_u_source_ext=0.0,
bc_mom_v_source_ext=0.0,
bc_mom_w_source_ext=0.0,
bc_mom_u_ham_ext=0.0,
bc_dmom_u_ham_grad_p_ext[nSpace],
bc_dmom_u_ham_grad_u_ext[nSpace],
bc_mom_v_ham_ext=0.0,
bc_dmom_v_ham_grad_p_ext[nSpace],
bc_dmom_v_ham_grad_v_ext[nSpace],
bc_mom_w_ham_ext=0.0,
bc_dmom_w_ham_grad_p_ext[nSpace],
bc_dmom_w_ham_grad_w_ext[nSpace],
jac_ext[nSpace*nSpace],
jacDet_ext,
jacInv_ext[nSpace*nSpace],
boundaryJac[nSpace*(nSpace-1)],
metricTensor[(nSpace-1)*(nSpace-1)],
metricTensorDetSqrt,
dS,p_test_dS[nDOF_test_element],vel_test_dS[nDOF_test_element],
p_grad_trial_trace[nDOF_trial_element*nSpace],vel_grad_trial_trace[nDOF_trial_element*nSpace],
vel_grad_test_dS[nDOF_trial_element*nSpace],
normal[2],x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
//VRANS
porosity_ext,
//
G[nSpace*nSpace],G_dd_G,tr_G,h_phi,h_penalty,penalty,
force_x,force_y,force_z,force_p_x,force_p_y,force_p_z,force_v_x,force_v_y,force_v_z,r_x,r_y,r_z;
//compute information about mapping from reference element to physical element
ck.calculateMapping_elementBoundary(eN,
ebN_local,
kb,
ebN_local_kb,
mesh_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
mesh_grad_trial_trace_ref.data(),
boundaryJac_ref.data(),
jac_ext,
jacDet_ext,
jacInv_ext,
boundaryJac,
metricTensor,
metricTensorDetSqrt,
normal_ref.data(),
normal,
x_ext,y_ext,z_ext);
ck.calculateMappingVelocity_elementBoundary(eN,
ebN_local,
kb,
ebN_local_kb,
mesh_velocity_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
xt_ext,yt_ext,zt_ext,
normal,
boundaryJac,
metricTensor,
integralScaling);
//xt_ext=0.0;yt_ext=0.0;zt_ext=0.0;
//std::cout<<"xt_ext "<<xt_ext<<'\t'<<yt_ext<<'\t'<<zt_ext<<std::endl;
//std::cout<<"x_ext "<<x_ext<<'\t'<<y_ext<<'\t'<<z_ext<<std::endl;
//std::cout<<"integralScaling - metricTensorDetSrt ==============================="<<integralScaling-metricTensorDetSqrt<<std::endl;
/* std::cout<<"metricTensorDetSqrt "<<metricTensorDetSqrt */
/* <<"dS_ref[kb]"<<dS_ref[kb]<<std::endl; */
//dS = ((1.0-MOVING_DOMAIN)*metricTensorDetSqrt + MOVING_DOMAIN*integralScaling)*dS_ref[kb];//cek need to test effect on accuracy
dS = metricTensorDetSqrt*dS_ref[kb];
//get the metric tensor
//cek todo use symmetry
ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
ck.calculateGScale(G,&ebqe_normal_phi_ext[ebNE_kb_nSpace],h_phi);
eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
double particle_eps = particle_epsFact*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
//compute shape and solution information
//shape
/* ck.gradTrialFromRef(&p_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,p_grad_trial_trace); */
ck.gradTrialFromRef(&vel_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,vel_grad_trial_trace);
//cek hack use trial ck.gradTrialFromRef(&vel_grad_test_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,vel_grad_test_trace);
//solution and gradients
/* ck.valFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],&p_trial_trace_ref[ebN_local_kb*nDOF_test_element],p_ext); */
p_ext = ebqe_p[ebNE_kb];
ck.valFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext);
ck.valFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],v_ext);
/* ck.valFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],w_ext); */
/* ck.gradFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],p_grad_trial_trace,grad_p_ext); */
for (int I=0;I<nSpace;I++)
grad_p_ext[I] = ebqe_grad_p[ebNE_kb_nSpace + I];
ck.gradFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_u_ext);
ck.gradFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_v_ext);
/* ck.gradFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_w_ext); */
//precalculate test function products with integration weights
for (int j=0;j<nDOF_trial_element;j++)
{
/* p_test_dS[j] = p_test_trace_ref[ebN_local_kb*nDOF_test_element+j]*dS; */
vel_test_dS[j] = vel_test_trace_ref[ebN_local_kb*nDOF_test_element+j]*dS;
for (int I=0;I<nSpace;I++)
vel_grad_test_dS[j*nSpace+I] = vel_grad_trial_trace[j*nSpace+I]*dS;//cek hack, using trial
}
bc_p_ext = isDOFBoundary_p[ebNE_kb]*ebqe_bc_p_ext[ebNE_kb]+(1-isDOFBoundary_p[ebNE_kb])*p_ext;
//note, our convention is that bc values at moving boundaries are relative to boundary velocity so we add it here
bc_u_ext = isDOFBoundary_u[ebNE_kb]*(ebqe_bc_u_ext[ebNE_kb] + MOVING_DOMAIN*xt_ext) + (1-isDOFBoundary_u[ebNE_kb])*u_ext;
bc_v_ext = isDOFBoundary_v[ebNE_kb]*(ebqe_bc_v_ext[ebNE_kb] + MOVING_DOMAIN*yt_ext) + (1-isDOFBoundary_v[ebNE_kb])*v_ext;
/* bc_w_ext = isDOFBoundary_w[ebNE_kb]*(ebqe_bc_w_ext[ebNE_kb] + MOVING_DOMAIN*zt_ext) + (1-isDOFBoundary_w[ebNE_kb])*w_ext; */
//VRANS
porosity_ext = 1.0 - ebqe_vos_ext[ebNE_kb];
//
//calculate the pde coefficients using the solution and the boundary values for the solution
//
double distance_to_omega_solid = 1e10;
if (use_ball_as_particle == 1)
{
get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(), x_ext, y_ext, z_ext, distance_to_omega_solid);
}
else
{
distance_to_omega_solid = ebq_global_phi_solid[ebN*nQuadraturePoints_elementBoundary+kb];
}
double eddy_viscosity_ext(0.),bc_eddy_viscosity_ext(0.); //not interested in saving boundary eddy viscosity for now
evaluateCoefficients(eps_rho,
eps_mu,
particle_eps,
sigma,
rho_0,
nu_0,
rho_1,
nu_1,
elementDiameter[eN],
smagorinskyConstant,
turbulenceClosureModel,
g.data(),
useVF,
ebqe_vf_ext[ebNE_kb],
ebqe_phi_ext[ebNE_kb],
&ebqe_normal_phi_ext[ebNE_kb_nSpace],
distance_to_omega_solid,
ebqe_kappa_phi_ext[ebNE_kb],
//VRANS
porosity_ext,
//
p_ext,
grad_p_ext,
grad_u_ext,
grad_v_ext,
grad_w_ext,
u_ext,
v_ext,
w_ext,
ebqe_velocity_star[ebNE_kb_nSpace+0],
ebqe_velocity_star[ebNE_kb_nSpace+1],
ebqe_velocity_star[ebNE_kb_nSpace+1],//hack,not used
eddy_viscosity_ext,
mom_u_acc_ext,
dmom_u_acc_u_ext,
mom_v_acc_ext,
dmom_v_acc_v_ext,
mom_w_acc_ext,
dmom_w_acc_w_ext,
mass_adv_ext,
dmass_adv_u_ext,
dmass_adv_v_ext,
dmass_adv_w_ext,
mom_u_adv_ext,
dmom_u_adv_u_ext,
dmom_u_adv_v_ext,
dmom_u_adv_w_ext,
mom_v_adv_ext,
dmom_v_adv_u_ext,
dmom_v_adv_v_ext,
dmom_v_adv_w_ext,
mom_w_adv_ext,
dmom_w_adv_u_ext,
dmom_w_adv_v_ext,
dmom_w_adv_w_ext,
mom_uu_diff_ten_ext,
mom_vv_diff_ten_ext,
mom_ww_diff_ten_ext,
mom_uv_diff_ten_ext,
mom_uw_diff_ten_ext,
mom_vu_diff_ten_ext,
mom_vw_diff_ten_ext,
mom_wu_diff_ten_ext,
mom_wv_diff_ten_ext,
mom_u_source_ext,
mom_v_source_ext,
mom_w_source_ext,
mom_u_ham_ext,
dmom_u_ham_grad_p_ext,
dmom_u_ham_grad_u_ext,
mom_v_ham_ext,
dmom_v_ham_grad_p_ext,
dmom_v_ham_grad_v_ext,
mom_w_ham_ext,
dmom_w_ham_grad_p_ext,
dmom_w_ham_grad_w_ext,
ebqe_rho[ebNE_kb],
ebqe_nu[ebNE_kb],
KILL_PRESSURE_TERM,
0,
0., // mql: zero force term at boundary
0.,
0.,
MATERIAL_PARAMETERS_AS_FUNCTION,
ebqe_density_as_function[ebNE_kb],
ebqe_dynamic_viscosity_as_function[ebNE_kb],
USE_SBM,
x_ext,y_ext,z_ext,
use_ball_as_particle,
ball_center.data(),
ball_radius.data(),
ball_velocity.data(),
ball_angular_velocity.data(),
INT_BY_PARTS_PRESSURE);
evaluateCoefficients(eps_rho,
eps_mu,
particle_eps,
sigma,
rho_0,
nu_0,
rho_1,
nu_1,
elementDiameter[eN],
smagorinskyConstant,
turbulenceClosureModel,
g.data(),
useVF,
bc_ebqe_vf_ext[ebNE_kb],
bc_ebqe_phi_ext[ebNE_kb],
&ebqe_normal_phi_ext[ebNE_kb_nSpace],
distance_to_omega_solid,
ebqe_kappa_phi_ext[ebNE_kb],
//VRANS
porosity_ext,
//
bc_p_ext,
grad_p_ext,
grad_u_ext,
grad_v_ext,
grad_w_ext,
bc_u_ext,
bc_v_ext,
bc_w_ext,
ebqe_velocity_star[ebNE_kb_nSpace+0],
ebqe_velocity_star[ebNE_kb_nSpace+1],
ebqe_velocity_star[ebNE_kb_nSpace+1],//hack,not used
bc_eddy_viscosity_ext,
bc_mom_u_acc_ext,
bc_dmom_u_acc_u_ext,
bc_mom_v_acc_ext,
bc_dmom_v_acc_v_ext,
bc_mom_w_acc_ext,
bc_dmom_w_acc_w_ext,
bc_mass_adv_ext,
bc_dmass_adv_u_ext,
bc_dmass_adv_v_ext,
bc_dmass_adv_w_ext,
bc_mom_u_adv_ext,
bc_dmom_u_adv_u_ext,
bc_dmom_u_adv_v_ext,
bc_dmom_u_adv_w_ext,
bc_mom_v_adv_ext,
bc_dmom_v_adv_u_ext,
bc_dmom_v_adv_v_ext,
bc_dmom_v_adv_w_ext,
bc_mom_w_adv_ext,
bc_dmom_w_adv_u_ext,
bc_dmom_w_adv_v_ext,
bc_dmom_w_adv_w_ext,
bc_mom_uu_diff_ten_ext,
bc_mom_vv_diff_ten_ext,
bc_mom_ww_diff_ten_ext,
bc_mom_uv_diff_ten_ext,
bc_mom_uw_diff_ten_ext,
bc_mom_vu_diff_ten_ext,
bc_mom_vw_diff_ten_ext,
bc_mom_wu_diff_ten_ext,
bc_mom_wv_diff_ten_ext,
bc_mom_u_source_ext,
bc_mom_v_source_ext,
bc_mom_w_source_ext,
bc_mom_u_ham_ext,
bc_dmom_u_ham_grad_p_ext,
bc_dmom_u_ham_grad_u_ext,
bc_mom_v_ham_ext,
bc_dmom_v_ham_grad_p_ext,
bc_dmom_v_ham_grad_v_ext,
bc_mom_w_ham_ext,
bc_dmom_w_ham_grad_p_ext,
bc_dmom_w_ham_grad_w_ext,
ebqe_rho[ebNE_kb],
ebqe_nu[ebNE_kb],
KILL_PRESSURE_TERM,
0,
0., // mql: zero force term at boundary
0.,
0.,
MATERIAL_PARAMETERS_AS_FUNCTION,
ebqe_density_as_function[ebNE_kb],
ebqe_dynamic_viscosity_as_function[ebNE_kb],
USE_SBM,
x_ext,y_ext,z_ext,
use_ball_as_particle,
ball_center.data(),
ball_radius.data(),
ball_velocity.data(),
ball_angular_velocity.data(),
INT_BY_PARTS_PRESSURE);
//Turbulence closure model
if (turbulenceClosureModel >= 3)
{
const double turb_var_grad_0_dummy[2] = {0.,0.};
const double c_mu = 0.09;//mwf hack
updateTurbulenceClosure(turbulenceClosureModel,
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
useVF,
ebqe_vf_ext[ebNE_kb],
ebqe_phi_ext[ebNE_kb],
porosity_ext,
c_mu, //mwf hack
ebqe_turb_var_0[ebNE_kb],
ebqe_turb_var_1[ebNE_kb],
turb_var_grad_0_dummy, //not needed
eddy_viscosity_ext,
mom_uu_diff_ten_ext,
mom_vv_diff_ten_ext,
mom_ww_diff_ten_ext,
mom_uv_diff_ten_ext,
mom_uw_diff_ten_ext,
mom_vu_diff_ten_ext,
mom_vw_diff_ten_ext,
mom_wu_diff_ten_ext,
mom_wv_diff_ten_ext,
mom_u_source_ext,
mom_v_source_ext,
mom_w_source_ext);
updateTurbulenceClosure(turbulenceClosureModel,
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
useVF,
bc_ebqe_vf_ext[ebNE_kb],
bc_ebqe_phi_ext[ebNE_kb],
porosity_ext,
c_mu, //mwf hack
ebqe_turb_var_0[ebNE_kb],
ebqe_turb_var_1[ebNE_kb],
turb_var_grad_0_dummy, //not needed
bc_eddy_viscosity_ext,
bc_mom_uu_diff_ten_ext,
bc_mom_vv_diff_ten_ext,
bc_mom_ww_diff_ten_ext,
bc_mom_uv_diff_ten_ext,
bc_mom_uw_diff_ten_ext,
bc_mom_vu_diff_ten_ext,
bc_mom_vw_diff_ten_ext,
bc_mom_wu_diff_ten_ext,
bc_mom_wv_diff_ten_ext,
bc_mom_u_source_ext,
bc_mom_v_source_ext,
bc_mom_w_source_ext);
}
//
//moving domain
//
mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*xt_ext; // times rho*porosity. mql. CHECK.
mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*yt_ext;
/* mom_u_adv_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*zt_ext; */
dmom_u_adv_u_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*xt_ext;
dmom_u_adv_u_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*yt_ext;
/* dmom_u_adv_u_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*zt_ext; */
mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*xt_ext;
mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*yt_ext;
/* mom_v_adv_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*zt_ext; */
dmom_v_adv_v_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*xt_ext;
dmom_v_adv_v_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*yt_ext;
/* dmom_v_adv_v_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*zt_ext; */
/* mom_w_adv_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*xt_ext; */
/* mom_w_adv_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*yt_ext; */
/* mom_w_adv_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*zt_ext; */
/* dmom_w_adv_w_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*xt_ext; */
/* dmom_w_adv_w_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*yt_ext; */
/* dmom_w_adv_w_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*zt_ext; */
//bc's
// mql. CHECK.
bc_mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*xt_ext;
bc_mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*yt_ext;
/* bc_mom_u_adv_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*zt_ext; */
bc_mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*xt_ext;
bc_mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*yt_ext;
/* bc_mom_v_adv_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*zt_ext; */
/* bc_mom_w_adv_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*xt_ext; */
/* bc_mom_w_adv_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*yt_ext; */
/* bc_mom_w_adv_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*zt_ext; */
//
//calculate the numerical fluxes
//
ck.calculateGScale(G,normal,h_penalty);
penalty = useMetrics*C_b/h_penalty + (1.0-useMetrics)*ebqe_penalty_ext[ebNE_kb];
exteriorNumericalAdvectiveFlux(isDOFBoundary_p[ebNE_kb],
isDOFBoundary_u[ebNE_kb],
isDOFBoundary_v[ebNE_kb],
isDOFBoundary_w[ebNE_kb],
isAdvectiveFluxBoundary_p[ebNE_kb],
isAdvectiveFluxBoundary_u[ebNE_kb],
isAdvectiveFluxBoundary_v[ebNE_kb],
isAdvectiveFluxBoundary_w[ebNE_kb],
dmom_u_ham_grad_p_ext[0],//=1/rho,
bc_dmom_u_ham_grad_p_ext[0],//=1/bc_rho,
normal,
dmom_u_acc_u_ext,
bc_p_ext,
bc_u_ext,
bc_v_ext,
bc_w_ext,
bc_mass_adv_ext,
bc_mom_u_adv_ext,
bc_mom_v_adv_ext,
bc_mom_w_adv_ext,
ebqe_bc_flux_mass_ext[ebNE_kb]+MOVING_DOMAIN*(xt_ext*normal[0]+yt_ext*normal[1]),//BC is relative mass flux
ebqe_bc_flux_mom_u_adv_ext[ebNE_kb],
ebqe_bc_flux_mom_v_adv_ext[ebNE_kb],
ebqe_bc_flux_mom_w_adv_ext[ebNE_kb],
p_ext,
u_ext,
v_ext,
w_ext,
mass_adv_ext,
mom_u_adv_ext,
mom_v_adv_ext,
mom_w_adv_ext,
dmass_adv_u_ext,
dmass_adv_v_ext,
dmass_adv_w_ext,
dmom_u_adv_p_ext,
dmom_u_adv_u_ext,
dmom_u_adv_v_ext,
dmom_u_adv_w_ext,
dmom_v_adv_p_ext,
dmom_v_adv_u_ext,
dmom_v_adv_v_ext,
dmom_v_adv_w_ext,
dmom_w_adv_p_ext,
dmom_w_adv_u_ext,
dmom_w_adv_v_ext,
dmom_w_adv_w_ext,
flux_mass_ext,
flux_mom_u_adv_ext,
flux_mom_v_adv_ext,
flux_mom_w_adv_ext,
&ebqe_velocity_star[ebNE_kb_nSpace],
&ebqe_velocity[ebNE_kb_nSpace]);
// mql: save gradient of solution for other models and to compute errors
for (int I=0;I<nSpace;I++)
{
ebqe_grad_u[ebNE_kb_nSpace+I] = grad_u_ext[I];
ebqe_grad_v[ebNE_kb_nSpace+I] = grad_v_ext[I];
/* ebqe_grad_w[ebNE_kb_nSpace+I] = grad_w_ext[I]; */
}
exteriorNumericalDiffusiveFlux(eps_rho,
ebqe_phi_ext[ebNE_kb],
sdInfo_u_u_rowptr.data(),
sdInfo_u_u_colind.data(),
isDOFBoundary_u[ebNE_kb],
isDiffusiveFluxBoundary_u[ebNE_kb],
normal,
bc_mom_uu_diff_ten_ext,
bc_u_ext,
ebqe_bc_flux_u_diff_ext[ebNE_kb],
mom_uu_diff_ten_ext,
grad_u_ext,
u_ext,
penalty,//ebqe_penalty_ext[ebNE_kb],
flux_mom_uu_diff_ext);
exteriorNumericalDiffusiveFlux(eps_rho,
ebqe_phi_ext[ebNE_kb],
sdInfo_u_v_rowptr.data(),
sdInfo_u_v_colind.data(),
isDOFBoundary_v[ebNE_kb],
isDiffusiveFluxBoundary_v[ebNE_kb],
normal,
bc_mom_uv_diff_ten_ext,
bc_v_ext,
0.0,//assume all of the flux gets applied in diagonal component
mom_uv_diff_ten_ext,
grad_v_ext,
v_ext,
penalty,//ebqe_penalty_ext[ebNE_kb],
flux_mom_uv_diff_ext);
/* exteriorNumericalDiffusiveFlux(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_u_w_rowptr, */
/* sdInfo_u_w_colind, */
/* isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_u[ebNE_kb], */
/* normal, */
/* bc_mom_uw_diff_ten_ext, */
/* bc_w_ext, */
/* 0.0,//see above */
/* mom_uw_diff_ten_ext, */
/* grad_w_ext, */
/* w_ext, */
/* penalty,//ebqe_penalty_ext[ebNE_kb], */
/* flux_mom_uw_diff_ext); */
exteriorNumericalDiffusiveFlux(eps_rho,
ebqe_phi_ext[ebNE_kb],
sdInfo_v_u_rowptr.data(),
sdInfo_v_u_colind.data(),
isDOFBoundary_u[ebNE_kb],
isDiffusiveFluxBoundary_u[ebNE_kb],
normal,
bc_mom_vu_diff_ten_ext,
bc_u_ext,
0.0,//see above
mom_vu_diff_ten_ext,
grad_u_ext,
u_ext,
penalty,//ebqe_penalty_ext[ebNE_kb],
flux_mom_vu_diff_ext);
exteriorNumericalDiffusiveFlux(eps_rho,
ebqe_phi_ext[ebNE_kb],
sdInfo_v_v_rowptr.data(),
sdInfo_v_v_colind.data(),
isDOFBoundary_v[ebNE_kb],
isDiffusiveFluxBoundary_v[ebNE_kb],
normal,
bc_mom_vv_diff_ten_ext,
bc_v_ext,
ebqe_bc_flux_v_diff_ext[ebNE_kb],
mom_vv_diff_ten_ext,
grad_v_ext,
v_ext,
penalty,//ebqe_penalty_ext[ebNE_kb],
flux_mom_vv_diff_ext);
/* exteriorNumericalDiffusiveFlux(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_v_w_rowptr, */
/* sdInfo_v_w_colind, */
/* isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_v[ebNE_kb], */
/* normal, */
/* bc_mom_vw_diff_ten_ext, */
/* bc_w_ext, */
/* 0.0,//see above */
/* mom_vw_diff_ten_ext, */
/* grad_w_ext, */
/* w_ext, */
/* penalty,//ebqe_penalty_ext[ebNE_kb], */
/* flux_mom_vw_diff_ext); */
/* exteriorNumericalDiffusiveFlux(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_w_u_rowptr, */
/* sdInfo_w_u_colind, */
/* isDOFBoundary_u[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* normal, */
/* bc_mom_wu_diff_ten_ext, */
/* bc_u_ext, */
/* 0.0,//see above */
/* mom_wu_diff_ten_ext, */
/* grad_u_ext, */
/* u_ext, */
/* penalty,//ebqe_penalty_ext[ebNE_kb], */
/* flux_mom_wu_diff_ext); */
/* exteriorNumericalDiffusiveFlux(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_w_v_rowptr, */
/* sdInfo_w_v_colind, */
/* isDOFBoundary_v[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* normal, */
/* bc_mom_wv_diff_ten_ext, */
/* bc_v_ext, */
/* 0.0,//see above */
/* mom_wv_diff_ten_ext, */
/* grad_v_ext, */
/* v_ext, */
/* penalty,//ebqe_penalty_ext[ebNE_kb], */
/* flux_mom_wv_diff_ext); */
/* exteriorNumericalDiffusiveFlux(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_w_w_rowptr, */
/* sdInfo_w_w_colind, */
/* isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* normal, */
/* bc_mom_ww_diff_ten_ext, */
/* bc_w_ext, */
/* ebqe_bc_flux_w_diff_ext[ebNE_kb], */
/* mom_ww_diff_ten_ext, */
/* grad_w_ext, */
/* w_ext, */
/* penalty,//ebqe_penalty_ext[ebNE_kb], */
/* flux_mom_ww_diff_ext); */
flux[ebN*nQuadraturePoints_elementBoundary+kb] = flux_mass_ext;
/* std::cout<<"external u,v,u_n " */
/* <<ebqe_velocity[ebNE_kb_nSpace+0]<<'\t' */
/* <<ebqe_velocity[ebNE_kb_nSpace+1]<<'\t' */
/* <<flux[ebN*nQuadraturePoints_elementBoundary+kb]<<std::endl; */
//
//integrate the net force and moment on flagged boundaries
//
if (ebN < nElementBoundaries_owned)
{
force_v_x = (flux_mom_u_adv_ext + flux_mom_uu_diff_ext + flux_mom_uv_diff_ext + flux_mom_uw_diff_ext)/dmom_u_ham_grad_p_ext[0];//same as *rho
force_v_y = (flux_mom_v_adv_ext + flux_mom_vu_diff_ext + flux_mom_vv_diff_ext + flux_mom_vw_diff_ext)/dmom_u_ham_grad_p_ext[0];
//force_v_z = (flux_mom_wu_diff_ext + flux_mom_wv_diff_ext + flux_mom_ww_diff_ext)/dmom_u_ham_grad_p_ext[0];
force_p_x = p_ext*normal[0];
force_p_y = p_ext*normal[1];
//force_p_z = p_ext*normal[2];
force_x = force_p_x + force_v_x;
force_y = force_p_y + force_v_y;
//force_z = force_p_z + force_v_z;
r_x = x_ext - barycenters[3*boundaryFlags[ebN]+0];
r_y = y_ext - barycenters[3*boundaryFlags[ebN]+1];
//r_z = z_ext - barycenters[3*boundaryFlags[ebN]+2];
wettedAreas[boundaryFlags[ebN]] += dS*(1.0-ebqe_vf_ext[ebNE_kb]);
netForces_p[3*boundaryFlags[ebN]+0] += force_p_x*dS;
netForces_p[3*boundaryFlags[ebN]+1] += force_p_y*dS;
//netForces_p[3*boundaryFlags[ebN]+2] += force_p_z*dS;
netForces_v[3*boundaryFlags[ebN]+0] += force_v_x*dS;
netForces_v[3*boundaryFlags[ebN]+1] += force_v_y*dS;
//netForces_v[3*boundaryFlags[ebN]+2] += force_v_z*dS;
//netMoments[3*boundaryFlags[ebN]+0] += (r_y*force_z - r_z*force_y)*dS;
//netMoments[3*boundaryFlags[ebN]+1] += (r_z*force_x - r_x*force_z)*dS;
netMoments[3*boundaryFlags[ebN]+2] += (r_x*force_y - r_y*force_x)*dS;
}
//
//update residuals
//
for (int i=0;i<nDOF_test_element;i++)
{
/* elementResidual_mesh[i] -= ck.ExteriorElementBoundaryFlux(MOVING_DOMAIN*(xt_ext*normal[0]+yt_ext*normal[1]),p_test_dS[i]); */
/* elementResidual_p[i] += ck.ExteriorElementBoundaryFlux(flux_mass_ext,p_test_dS[i]); */
/* elementResidual_p[i] -= DM*ck.ExteriorElementBoundaryFlux(MOVING_DOMAIN*(xt_ext*normal[0]+yt_ext*normal[1]),p_test_dS[i]); */
/* globalConservationError += ck.ExteriorElementBoundaryFlux(flux_mass_ext,p_test_dS[i]); */
elementResidual_u[i] +=
(INT_BY_PARTS_PRESSURE==1 ? p_ext*vel_test_dS[i]*normal[0] : 0.) +
ck.ExteriorElementBoundaryFlux(flux_mom_u_adv_ext,vel_test_dS[i])+
ck.ExteriorElementBoundaryFlux(flux_mom_uu_diff_ext,vel_test_dS[i])+
ck.ExteriorElementBoundaryFlux(flux_mom_uv_diff_ext,vel_test_dS[i])+
ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u[ebNE_kb],
isDiffusiveFluxBoundary_u[ebNE_kb],
eb_adjoint_sigma,
u_ext,
bc_u_ext,
normal,
sdInfo_u_u_rowptr.data(),
sdInfo_u_u_colind.data(),
mom_uu_diff_ten_ext,
&vel_grad_test_dS[i*nSpace])+
ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v[ebNE_kb],
isDiffusiveFluxBoundary_u[ebNE_kb],
eb_adjoint_sigma,
v_ext,
bc_v_ext,
normal,
sdInfo_u_v_rowptr.data(),
sdInfo_u_v_colind.data(),
mom_uv_diff_ten_ext,
&vel_grad_test_dS[i*nSpace]);//+
/* ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_u[ebNE_kb], */
/* eb_adjoint_sigma, */
/* w_ext, */
/* bc_w_ext, */
/* normal, */
/* sdInfo_u_w_rowptr, */
/* sdInfo_u_w_colind, */
/* mom_uw_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace]); */
elementResidual_v[i] +=
(INT_BY_PARTS_PRESSURE==1 ? p_ext*vel_test_dS[i]*normal[1] : 0.) +
ck.ExteriorElementBoundaryFlux(flux_mom_v_adv_ext,vel_test_dS[i]) +
ck.ExteriorElementBoundaryFlux(flux_mom_vu_diff_ext,vel_test_dS[i])+
ck.ExteriorElementBoundaryFlux(flux_mom_vv_diff_ext,vel_test_dS[i])+
ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u[ebNE_kb],
isDiffusiveFluxBoundary_v[ebNE_kb],
eb_adjoint_sigma,
u_ext,
bc_u_ext,
normal,
sdInfo_v_u_rowptr.data(),
sdInfo_v_u_colind.data(),
mom_vu_diff_ten_ext,
&vel_grad_test_dS[i*nSpace])+
ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v[ebNE_kb],
isDiffusiveFluxBoundary_v[ebNE_kb],
eb_adjoint_sigma,
v_ext,
bc_v_ext,
normal,
sdInfo_v_v_rowptr.data(),
sdInfo_v_v_colind.data(),
mom_vv_diff_ten_ext,
&vel_grad_test_dS[i*nSpace]);//+
/* ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_v[ebNE_kb], */
/* eb_adjoint_sigma, */
/* w_ext, */
/* bc_w_ext, */
/* normal, */
/* sdInfo_v_w_rowptr, */
/* sdInfo_v_w_colind, */
/* mom_vw_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace]); */
/* elementResidual_w[i] += */
/* (INT_BY_PARTS_PRESSURE==1 ? p_ext*vel_test_dS[i]*normal[2] : 0.) +*/
/* ck.ExteriorElementBoundaryFlux(flux_mom_w_adv_ext,vel_test_dS[i]) + */
/* ck.ExteriorElementBoundaryFlux(flux_mom_wu_diff_ext,vel_test_dS[i])+ */
/* ck.ExteriorElementBoundaryFlux(flux_mom_wv_diff_ext,vel_test_dS[i])+ */
/* ck.ExteriorElementBoundaryFlux(flux_mom_ww_diff_ext,vel_test_dS[i])+ */
/* ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* eb_adjoint_sigma, */
/* u_ext, */
/* bc_u_ext, */
/* normal, */
/* sdInfo_w_u_rowptr, */
/* sdInfo_w_u_colind, */
/* mom_wu_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace])+ */
/* ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* eb_adjoint_sigma, */
/* v_ext, */
/* bc_v_ext, */
/* normal, */
/* sdInfo_w_v_rowptr, */
/* sdInfo_w_v_colind, */
/* mom_wv_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace])+ */
/* ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* eb_adjoint_sigma, */
/* w_ext, */
/* bc_w_ext, */
/* normal, */
/* sdInfo_w_w_rowptr, */
/* sdInfo_w_w_colind, */
/* mom_ww_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace]); */
}//i
}//kb
//
//update the element and global residual storage
//
for (int i=0;i<nDOF_test_element;i++)
{
int eN_i = eN*nDOF_test_element+i;
/* elementResidual_p_save[eN_i] += elementResidual_p[i]; */
/* mesh_volume_conservation_weak += elementResidual_mesh[i]; */
/* globalResidual[offset_p+stride_p*p_l2g[eN_i]]+=elementResidual_p[i]; */
globalResidual[offset_u+stride_u*vel_l2g[eN_i]]+=elementResidual_u[i];
globalResidual[offset_v+stride_v*vel_l2g[eN_i]]+=elementResidual_v[i];
/* globalResidual[offset_w+stride_w*vel_l2g[eN_i]]+=elementResidual_w[i]; */
}//i
}//ebNE
gf.useExact=useExact;
gf_s.useExact=useExact;
/* std::cout<<"mesh volume conservation = "<<mesh_volume_conservation<<std::endl; */
/* std::cout<<"mesh volume conservation weak = "<<mesh_volume_conservation_weak<<std::endl; */
/* std::cout<<"mesh volume conservation err max= "<<mesh_volume_conservation_err_max<<std::endl; */
/* std::cout<<"mesh volume conservation err max weak = "<<mesh_volume_conservation_err_max_weak<<std::endl; */
if (CUT_CELL_INTEGRATION)
{
particle_surfaceArea[0] = cut_cell_boundary_length;
particle_netForces[(0+nParticles)*3 +0] = p_force_x;
particle_netForces[(0+nParticles)*3 +1] = p_force_y;
std::cout<<"===end mesh==="<<std::endl<<std::flush;
}
}
void calculateJacobian(arguments_dict& args,
bool useExact)
{
xt::pyarray<double>& mesh_trial_ref = args.m_darray["mesh_trial_ref"];
xt::pyarray<double>& mesh_grad_trial_ref = args.m_darray["mesh_grad_trial_ref"];
xt::pyarray<double>& mesh_dof = args.m_darray["mesh_dof"];
xt::pyarray<double>& mesh_velocity_dof = args.m_darray["mesh_velocity_dof"];
double MOVING_DOMAIN = args.m_dscalar["MOVING_DOMAIN"];
double PSTAB = args.m_dscalar["PSTAB"];
xt::pyarray<int>& mesh_l2g = args.m_iarray["mesh_l2g"];
xt::pyarray<double>& x_ref = args.m_darray["x_ref"];
xt::pyarray<double>& dV_ref = args.m_darray["dV_ref"];
xt::pyarray<double>& p_trial_ref = args.m_darray["p_trial_ref"];
xt::pyarray<double>& p_grad_trial_ref = args.m_darray["p_grad_trial_ref"];
xt::pyarray<double>& p_test_ref = args.m_darray["p_test_ref"];
xt::pyarray<double>& p_grad_test_ref = args.m_darray["p_grad_test_ref"];
xt::pyarray<double>& q_p = args.m_darray["q_p"];
xt::pyarray<double>& q_grad_p = args.m_darray["q_grad_p"];
xt::pyarray<double>& ebqe_p = args.m_darray["ebqe_p"];
xt::pyarray<double>& ebqe_grad_p = args.m_darray["ebqe_grad_p"];
xt::pyarray<double>& vel_trial_ref = args.m_darray["vel_trial_ref"];
xt::pyarray<double>& vel_grad_trial_ref = args.m_darray["vel_grad_trial_ref"];
xt::pyarray<double>& vel_hess_trial_ref = args.m_darray["vel_hess_trial_ref"];
xt::pyarray<double>& vel_test_ref = args.m_darray["vel_test_ref"];
xt::pyarray<double>& vel_grad_test_ref = args.m_darray["vel_grad_test_ref"];
xt::pyarray<double>& mesh_trial_trace_ref = args.m_darray["mesh_trial_trace_ref"];
xt::pyarray<double>& mesh_grad_trial_trace_ref = args.m_darray["mesh_grad_trial_trace_ref"];
xt::pyarray<double>& dS_ref = args.m_darray["dS_ref"];
xt::pyarray<double>& p_trial_trace_ref = args.m_darray["p_trial_trace_ref"];
xt::pyarray<double>& p_grad_trial_trace_ref = args.m_darray["p_grad_trial_trace_ref"];
xt::pyarray<double>& p_test_trace_ref = args.m_darray["p_test_trace_ref"];
xt::pyarray<double>& p_grad_test_trace_ref = args.m_darray["p_grad_test_trace_ref"];
xt::pyarray<double>& vel_trial_trace_ref = args.m_darray["vel_trial_trace_ref"];
xt::pyarray<double>& vel_grad_trial_trace_ref = args.m_darray["vel_grad_trial_trace_ref"];
xt::pyarray<double>& vel_test_trace_ref = args.m_darray["vel_test_trace_ref"];
xt::pyarray<double>& vel_grad_test_trace_ref = args.m_darray["vel_grad_test_trace_ref"];
xt::pyarray<double>& normal_ref = args.m_darray["normal_ref"];
xt::pyarray<double>& boundaryJac_ref = args.m_darray["boundaryJac_ref"];
double eb_adjoint_sigma = args.m_dscalar["eb_adjoint_sigma"];
xt::pyarray<double>& elementDiameter = args.m_darray["elementDiameter"];
xt::pyarray<double>& nodeDiametersArray = args.m_darray["nodeDiametersArray"];
double hFactor = args.m_dscalar["hFactor"];
int nElements_global = args.m_iscalar["nElements_global"];
int nElements_owned = args.m_iscalar["nElements_owned"];
int nElementBoundaries_global = args.m_iscalar["nElementBoundaries_global"];
int nElementBoundaries_owned = args.m_iscalar["nElementBoundaries_owned"];
int nNodes_owned = args.m_iscalar["nNodes_owned"];
double useRBLES = args.m_dscalar["useRBLES"];
double useMetrics = args.m_dscalar["useMetrics"];
double alphaBDF = args.m_dscalar["alphaBDF"];
double epsFact_rho = args.m_dscalar["epsFact_rho"];
double epsFact_mu = args.m_dscalar["epsFact_mu"];
double sigma = args.m_dscalar["sigma"];
double rho_0 = args.m_dscalar["rho_0"];
double nu_0 = args.m_dscalar["nu_0"];
double rho_1 = args.m_dscalar["rho_1"];
double nu_1 = args.m_dscalar["nu_1"];
double smagorinskyConstant = args.m_dscalar["smagorinskyConstant"];
int turbulenceClosureModel = args.m_iscalar["turbulenceClosureModel"];
double Ct_sge = args.m_dscalar["Ct_sge"];
double Cd_sge = args.m_dscalar["Cd_sge"];
double C_dg = args.m_dscalar["C_dg"];
double C_b = args.m_dscalar["C_b"];
const xt::pyarray<double>& eps_solid = args.m_darray["eps_solid"];
const xt::pyarray<double>& ebq_global_phi_solid = args.m_darray["ebq_global_phi_solid"];
const xt::pyarray<double>& ebq_global_grad_phi_solid = args.m_darray["ebq_global_grad_phi_solid"];
const xt::pyarray<double>& ebq_particle_velocity_solid = args.m_darray["ebq_particle_velocity_solid"];
xt::pyarray<double>& phi_solid_nodes = args.m_darray["phi_solid_nodes"];
const xt::pyarray<double>& phi_solid = args.m_darray["phi_solid"];
const xt::pyarray<double>& q_velocity_solid = args.m_darray["q_velocity_solid"];
const xt::pyarray<double>& q_velocityStar_solid = args.m_darray["q_velocityStar_solid"];
const xt::pyarray<double>& q_vos = args.m_darray["q_vos"];
const xt::pyarray<double>& q_dvos_dt = args.m_darray["q_dvos_dt"];
const xt::pyarray<double>& q_grad_vos = args.m_darray["q_grad_vos"];
const xt::pyarray<double>& q_dragAlpha = args.m_darray["q_dragAlpha"];
const xt::pyarray<double>& q_dragBeta = args.m_darray["q_dragBeta"];
const xt::pyarray<double>& q_mass_source = args.m_darray["q_mass_source"];
const xt::pyarray<double>& q_turb_var_0 = args.m_darray["q_turb_var_0"];
const xt::pyarray<double>& q_turb_var_1 = args.m_darray["q_turb_var_1"];
const xt::pyarray<double>& q_turb_var_grad_0 = args.m_darray["q_turb_var_grad_0"];
xt::pyarray<int>& p_l2g = args.m_iarray["p_l2g"];
xt::pyarray<int>& vel_l2g = args.m_iarray["vel_l2g"];
xt::pyarray<double>& p_dof = args.m_darray["p_dof"];
xt::pyarray<double>& u_dof = args.m_darray["u_dof"];
xt::pyarray<double>& v_dof = args.m_darray["v_dof"];
xt::pyarray<double>& w_dof = args.m_darray["w_dof"];
xt::pyarray<double>& g = args.m_darray["g"];
const double useVF = args.m_dscalar["useVF"];
xt::pyarray<double>& vf = args.m_darray["vf"];
xt::pyarray<double>& phi = args.m_darray["phi"];
xt::pyarray<double>& phi_dof = args.m_darray["phi_dof"];
xt::pyarray<double>& normal_phi = args.m_darray["normal_phi"];
xt::pyarray<double>& kappa_phi = args.m_darray["kappa_phi"];
xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.m_darray["q_mom_u_acc_beta_bdf"];
xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.m_darray["q_mom_v_acc_beta_bdf"];
xt::pyarray<double>& q_mom_w_acc_beta_bdf = args.m_darray["q_mom_w_acc_beta_bdf"];
xt::pyarray<double>& q_dV = args.m_darray["q_dV"];
xt::pyarray<double>& q_dV_last = args.m_darray["q_dV_last"];
xt::pyarray<double>& q_velocity_sge = args.m_darray["q_velocity_sge"];
xt::pyarray<double>& ebqe_velocity_star = args.m_darray["ebqe_velocity_star"];
xt::pyarray<double>& q_cfl = args.m_darray["q_cfl"];
xt::pyarray<double>& q_numDiff_u_last = args.m_darray["q_numDiff_u_last"];
xt::pyarray<double>& q_numDiff_v_last = args.m_darray["q_numDiff_v_last"];
xt::pyarray<double>& q_numDiff_w_last = args.m_darray["q_numDiff_w_last"];
xt::pyarray<int>& sdInfo_u_u_rowptr = args.m_iarray["sdInfo_u_u_rowptr"];
xt::pyarray<int>& sdInfo_u_u_colind = args.m_iarray["sdInfo_u_u_colind"];
xt::pyarray<int>& sdInfo_u_v_rowptr = args.m_iarray["sdInfo_u_v_rowptr"];
xt::pyarray<int>& sdInfo_u_v_colind = args.m_iarray["sdInfo_u_v_colind"];
xt::pyarray<int>& sdInfo_u_w_rowptr = args.m_iarray["sdInfo_u_w_rowptr"];
xt::pyarray<int>& sdInfo_u_w_colind = args.m_iarray["sdInfo_u_w_colind"];
xt::pyarray<int>& sdInfo_v_v_rowptr = args.m_iarray["sdInfo_v_v_rowptr"];
xt::pyarray<int>& sdInfo_v_v_colind = args.m_iarray["sdInfo_v_v_colind"];
xt::pyarray<int>& sdInfo_v_u_rowptr = args.m_iarray["sdInfo_v_u_rowptr"];
xt::pyarray<int>& sdInfo_v_u_colind = args.m_iarray["sdInfo_v_u_colind"];
xt::pyarray<int>& sdInfo_v_w_rowptr = args.m_iarray["sdInfo_v_w_rowptr"];
xt::pyarray<int>& sdInfo_v_w_colind = args.m_iarray["sdInfo_v_w_colind"];
xt::pyarray<int>& sdInfo_w_w_rowptr = args.m_iarray["sdInfo_w_w_rowptr"];
xt::pyarray<int>& sdInfo_w_w_colind = args.m_iarray["sdInfo_w_w_colind"];
xt::pyarray<int>& sdInfo_w_u_rowptr = args.m_iarray["sdInfo_w_u_rowptr"];
xt::pyarray<int>& sdInfo_w_u_colind = args.m_iarray["sdInfo_w_u_colind"];
xt::pyarray<int>& sdInfo_w_v_rowptr = args.m_iarray["sdInfo_w_v_rowptr"];
xt::pyarray<int>& sdInfo_w_v_colind = args.m_iarray["sdInfo_w_v_colind"];
xt::pyarray<int>& csrRowIndeces_p_p = args.m_iarray["csrRowIndeces_p_p"];
xt::pyarray<int>& csrColumnOffsets_p_p = args.m_iarray["csrColumnOffsets_p_p"];
xt::pyarray<int>& csrRowIndeces_p_u = args.m_iarray["csrRowIndeces_p_u"];
xt::pyarray<int>& csrColumnOffsets_p_u = args.m_iarray["csrColumnOffsets_p_u"];
xt::pyarray<int>& csrRowIndeces_p_v = args.m_iarray["csrRowIndeces_p_v"];
xt::pyarray<int>& csrColumnOffsets_p_v = args.m_iarray["csrColumnOffsets_p_v"];
xt::pyarray<int>& csrRowIndeces_p_w = args.m_iarray["csrRowIndeces_p_w"];
xt::pyarray<int>& csrColumnOffsets_p_w = args.m_iarray["csrColumnOffsets_p_w"];
xt::pyarray<int>& csrRowIndeces_u_p = args.m_iarray["csrRowIndeces_u_p"];
xt::pyarray<int>& csrColumnOffsets_u_p = args.m_iarray["csrColumnOffsets_u_p"];
xt::pyarray<int>& csrRowIndeces_u_u = args.m_iarray["csrRowIndeces_u_u"];
xt::pyarray<int>& csrColumnOffsets_u_u = args.m_iarray["csrColumnOffsets_u_u"];
xt::pyarray<int>& csrRowIndeces_u_v = args.m_iarray["csrRowIndeces_u_v"];
xt::pyarray<int>& csrColumnOffsets_u_v = args.m_iarray["csrColumnOffsets_u_v"];
xt::pyarray<int>& csrRowIndeces_u_w = args.m_iarray["csrRowIndeces_u_w"];
xt::pyarray<int>& csrColumnOffsets_u_w = args.m_iarray["csrColumnOffsets_u_w"];
xt::pyarray<int>& csrRowIndeces_v_p = args.m_iarray["csrRowIndeces_v_p"];
xt::pyarray<int>& csrColumnOffsets_v_p = args.m_iarray["csrColumnOffsets_v_p"];
xt::pyarray<int>& csrRowIndeces_v_u = args.m_iarray["csrRowIndeces_v_u"];
xt::pyarray<int>& csrColumnOffsets_v_u = args.m_iarray["csrColumnOffsets_v_u"];
xt::pyarray<int>& csrRowIndeces_v_v = args.m_iarray["csrRowIndeces_v_v"];
xt::pyarray<int>& csrColumnOffsets_v_v = args.m_iarray["csrColumnOffsets_v_v"];
xt::pyarray<int>& csrRowIndeces_v_w = args.m_iarray["csrRowIndeces_v_w"];
xt::pyarray<int>& csrColumnOffsets_v_w = args.m_iarray["csrColumnOffsets_v_w"];
xt::pyarray<int>& csrRowIndeces_w_p = args.m_iarray["csrRowIndeces_w_p"];
xt::pyarray<int>& csrColumnOffsets_w_p = args.m_iarray["csrColumnOffsets_w_p"];
xt::pyarray<int>& csrRowIndeces_w_u = args.m_iarray["csrRowIndeces_w_u"];
xt::pyarray<int>& csrColumnOffsets_w_u = args.m_iarray["csrColumnOffsets_w_u"];
xt::pyarray<int>& csrRowIndeces_w_v = args.m_iarray["csrRowIndeces_w_v"];
xt::pyarray<int>& csrColumnOffsets_w_v = args.m_iarray["csrColumnOffsets_w_v"];
xt::pyarray<int>& csrRowIndeces_w_w = args.m_iarray["csrRowIndeces_w_w"];
xt::pyarray<int>& csrColumnOffsets_w_w = args.m_iarray["csrColumnOffsets_w_w"];
xt::pyarray<double>& globalJacobian = args.m_darray["globalJacobian"];
int nExteriorElementBoundaries_global = args.m_iscalar["nExteriorElementBoundaries_global"];
xt::pyarray<int>& exteriorElementBoundariesArray = args.m_iarray["exteriorElementBoundariesArray"];
xt::pyarray<int>& elementBoundariesArray = args.m_iarray["elementBoundariesArray"];
xt::pyarray<int>& elementBoundaryElementsArray = args.m_iarray["elementBoundaryElementsArray"];
xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.m_iarray["elementBoundaryLocalElementBoundariesArray"];
xt::pyarray<double>& ebqe_vf_ext = args.m_darray["ebqe_vf_ext"];
xt::pyarray<double>& bc_ebqe_vf_ext = args.m_darray["bc_ebqe_vf_ext"];
xt::pyarray<double>& ebqe_phi_ext = args.m_darray["ebqe_phi_ext"];
xt::pyarray<double>& bc_ebqe_phi_ext = args.m_darray["bc_ebqe_phi_ext"];
xt::pyarray<double>& ebqe_normal_phi_ext = args.m_darray["ebqe_normal_phi_ext"];
xt::pyarray<double>& ebqe_kappa_phi_ext = args.m_darray["ebqe_kappa_phi_ext"];
const xt::pyarray<double>& ebqe_vos_ext = args.m_darray["ebqe_vos_ext"];
const xt::pyarray<double>& ebqe_turb_var_0 = args.m_darray["ebqe_turb_var_0"];
const xt::pyarray<double>& ebqe_turb_var_1 = args.m_darray["ebqe_turb_var_1"];
xt::pyarray<int>& isDOFBoundary_p = args.m_iarray["isDOFBoundary_p"];
xt::pyarray<int>& isDOFBoundary_u = args.m_iarray["isDOFBoundary_u"];
xt::pyarray<int>& isDOFBoundary_v = args.m_iarray["isDOFBoundary_v"];
xt::pyarray<int>& isDOFBoundary_w = args.m_iarray["isDOFBoundary_w"];
xt::pyarray<int>& isAdvectiveFluxBoundary_p = args.m_iarray["isAdvectiveFluxBoundary_p"];
xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.m_iarray["isAdvectiveFluxBoundary_u"];
xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.m_iarray["isAdvectiveFluxBoundary_v"];
xt::pyarray<int>& isAdvectiveFluxBoundary_w = args.m_iarray["isAdvectiveFluxBoundary_w"];
xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.m_iarray["isDiffusiveFluxBoundary_u"];
xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.m_iarray["isDiffusiveFluxBoundary_v"];
xt::pyarray<int>& isDiffusiveFluxBoundary_w = args.m_iarray["isDiffusiveFluxBoundary_w"];
xt::pyarray<double>& ebqe_bc_p_ext = args.m_darray["ebqe_bc_p_ext"];
xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.m_darray["ebqe_bc_flux_mass_ext"];
xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.m_darray["ebqe_bc_flux_mom_u_adv_ext"];
xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.m_darray["ebqe_bc_flux_mom_v_adv_ext"];
xt::pyarray<double>& ebqe_bc_flux_mom_w_adv_ext = args.m_darray["ebqe_bc_flux_mom_w_adv_ext"];
xt::pyarray<double>& ebqe_bc_u_ext = args.m_darray["ebqe_bc_u_ext"];
xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.m_darray["ebqe_bc_flux_u_diff_ext"];
xt::pyarray<double>& ebqe_penalty_ext = args.m_darray["ebqe_penalty_ext"];
xt::pyarray<double>& ebqe_bc_v_ext = args.m_darray["ebqe_bc_v_ext"];
xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.m_darray["ebqe_bc_flux_v_diff_ext"];
xt::pyarray<double>& ebqe_bc_w_ext = args.m_darray["ebqe_bc_w_ext"];
xt::pyarray<double>& ebqe_bc_flux_w_diff_ext = args.m_darray["ebqe_bc_flux_w_diff_ext"];
xt::pyarray<int>& csrColumnOffsets_eb_p_p = args.m_iarray["csrColumnOffsets_eb_p_p"];
xt::pyarray<int>& csrColumnOffsets_eb_p_u = args.m_iarray["csrColumnOffsets_eb_p_u"];
xt::pyarray<int>& csrColumnOffsets_eb_p_v = args.m_iarray["csrColumnOffsets_eb_p_v"];
xt::pyarray<int>& csrColumnOffsets_eb_p_w = args.m_iarray["csrColumnOffsets_eb_p_w"];
xt::pyarray<int>& csrColumnOffsets_eb_u_p = args.m_iarray["csrColumnOffsets_eb_u_p"];
xt::pyarray<int>& csrColumnOffsets_eb_u_u = args.m_iarray["csrColumnOffsets_eb_u_u"];
xt::pyarray<int>& csrColumnOffsets_eb_u_v = args.m_iarray["csrColumnOffsets_eb_u_v"];
xt::pyarray<int>& csrColumnOffsets_eb_u_w = args.m_iarray["csrColumnOffsets_eb_u_w"];
xt::pyarray<int>& csrColumnOffsets_eb_v_p = args.m_iarray["csrColumnOffsets_eb_v_p"];
xt::pyarray<int>& csrColumnOffsets_eb_v_u = args.m_iarray["csrColumnOffsets_eb_v_u"];
xt::pyarray<int>& csrColumnOffsets_eb_v_v = args.m_iarray["csrColumnOffsets_eb_v_v"];
xt::pyarray<int>& csrColumnOffsets_eb_v_w = args.m_iarray["csrColumnOffsets_eb_v_w"];
xt::pyarray<int>& csrColumnOffsets_eb_w_p = args.m_iarray["csrColumnOffsets_eb_w_p"];
xt::pyarray<int>& csrColumnOffsets_eb_w_u = args.m_iarray["csrColumnOffsets_eb_w_u"];
xt::pyarray<int>& csrColumnOffsets_eb_w_v = args.m_iarray["csrColumnOffsets_eb_w_v"];
xt::pyarray<int>& csrColumnOffsets_eb_w_w = args.m_iarray["csrColumnOffsets_eb_w_w"];
xt::pyarray<int>& elementFlags = args.m_iarray["elementFlags"];
int nParticles = args.m_iscalar["nParticles"];
double particle_epsFact = args.m_dscalar["particle_epsFact"];
double particle_alpha = args.m_dscalar["particle_alpha"];
double particle_beta = args.m_dscalar["particle_beta"];
double particle_penalty_constant = args.m_dscalar["particle_penalty_constant"];
xt::pyarray<double>& particle_signed_distances = args.m_darray["particle_signed_distances"];
xt::pyarray<double>& particle_signed_distance_normals = args.m_darray["particle_signed_distance_normals"];
xt::pyarray<double>& particle_velocities = args.m_darray["particle_velocities"];
xt::pyarray<double>& particle_centroids = args.m_darray["particle_centroids"];
double particle_nitsche = args.m_dscalar["particle_nitsche"];
int use_ball_as_particle = args.m_iscalar["use_ball_as_particle"];
xt::pyarray<double>& ball_center = args.m_darray["ball_center"];
xt::pyarray<double>& ball_radius = args.m_darray["ball_radius"];
xt::pyarray<double>& ball_velocity = args.m_darray["ball_velocity"];
xt::pyarray<double>& ball_angular_velocity = args.m_darray["ball_angular_velocity"];
int USE_SUPG = args.m_iscalar["USE_SUPG"];
int KILL_PRESSURE_TERM = args.m_iscalar["KILL_PRESSURE_TERM"];
double dt = args.m_dscalar["dt"];
int MATERIAL_PARAMETERS_AS_FUNCTION = args.m_iscalar["MATERIAL_PARAMETERS_AS_FUNCTION"];
xt::pyarray<double>& density_as_function = args.m_darray["density_as_function"];
xt::pyarray<double>& dynamic_viscosity_as_function = args.m_darray["dynamic_viscosity_as_function"];
xt::pyarray<double>& ebqe_density_as_function = args.m_darray["ebqe_density_as_function"];
xt::pyarray<double>& ebqe_dynamic_viscosity_as_function = args.m_darray["ebqe_dynamic_viscosity_as_function"];
int USE_SBM = args.m_iscalar["USE_SBM"];
int ARTIFICIAL_VISCOSITY = args.m_iscalar["ARTIFICIAL_VISCOSITY"];
xt::pyarray<double>& uStar_dMatrix = args.m_darray["uStar_dMatrix"];
xt::pyarray<double>& vStar_dMatrix = args.m_darray["vStar_dMatrix"];
xt::pyarray<double>& wStar_dMatrix = args.m_darray["wStar_dMatrix"];
int numDOFs_1D = args.m_iscalar["numDOFs_1D"];
int offset_u = args.m_iscalar["offset_u"];
int offset_v = args.m_iscalar["offset_v"];
int offset_w = args.m_iscalar["offset_w"];
int stride_u = args.m_iscalar["stride_u"];
int stride_v = args.m_iscalar["stride_v"];
int stride_w = args.m_iscalar["stride_w"];
xt::pyarray<int>& rowptr_1D = args.m_iarray["rowptr_1D"];
xt::pyarray<int>& colind_1D = args.m_iarray["colind_1D"];
xt::pyarray<int>& rowptr = args.m_iarray["rowptr"];
xt::pyarray<int>& colind = args.m_iarray["colind"];
int INT_BY_PARTS_PRESSURE = args.m_iscalar["INT_BY_PARTS_PRESSURE"];
//
//loop over elements to compute volume integrals and load them into the element Jacobians and global Jacobian
//
std::valarray<double> particle_surfaceArea(nParticles), particle_netForces(nParticles*3*3), particle_netMoments(nParticles*3);
const int nQuadraturePoints_global(nElements_global*nQuadraturePoints_element);
for(int eN=0;eN<nElements_global;eN++)
{
register double eps_rho,eps_mu;
double element_active=1.0;//value 1 is because it is ibm by default
register double elementJacobian_p_p[nDOF_test_element][nDOF_trial_element],
elementJacobian_p_u[nDOF_test_element][nDOF_trial_element],
elementJacobian_p_v[nDOF_test_element][nDOF_trial_element],
elementJacobian_p_w[nDOF_test_element][nDOF_trial_element],
elementJacobian_u_p[nDOF_test_element][nDOF_trial_element],
elementJacobian_u_u[nDOF_test_element][nDOF_trial_element],
elementJacobian_u_v[nDOF_test_element][nDOF_trial_element],
elementJacobian_u_w[nDOF_test_element][nDOF_trial_element],
elementJacobian_v_p[nDOF_test_element][nDOF_trial_element],
elementJacobian_v_u[nDOF_test_element][nDOF_trial_element],
elementJacobian_v_v[nDOF_test_element][nDOF_trial_element],
elementJacobian_v_w[nDOF_test_element][nDOF_trial_element],
elementJacobian_w_p[nDOF_test_element][nDOF_trial_element],
elementJacobian_w_u[nDOF_test_element][nDOF_trial_element],
elementJacobian_w_v[nDOF_test_element][nDOF_trial_element],
elementJacobian_w_w[nDOF_test_element][nDOF_trial_element];
for (int i=0;i<nDOF_test_element;i++)
for (int j=0;j<nDOF_trial_element;j++)
{
elementJacobian_p_p[i][j]=0.0;
elementJacobian_p_u[i][j]=0.0;
elementJacobian_p_v[i][j]=0.0;
elementJacobian_p_w[i][j]=0.0;
elementJacobian_u_p[i][j]=0.0;
elementJacobian_u_u[i][j]=0.0;
elementJacobian_u_v[i][j]=0.0;
elementJacobian_u_w[i][j]=0.0;
elementJacobian_v_p[i][j]=0.0;
elementJacobian_v_u[i][j]=0.0;
elementJacobian_v_v[i][j]=0.0;
elementJacobian_v_w[i][j]=0.0;
elementJacobian_w_p[i][j]=0.0;
elementJacobian_w_u[i][j]=0.0;
elementJacobian_w_v[i][j]=0.0;
elementJacobian_w_w[i][j]=0.0;
}
//
//detect cut cells
//
//if(0)
if(USE_SBM>0)
{
//
//detect cut cells
//
double _distance[nDOF_mesh_trial_element]={0.0};
int pos_counter=0;
for (int I=0;I<nDOF_mesh_trial_element;I++)
{
if(use_ball_as_particle==1)
{
get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(),
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+0],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+1],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+2],
_distance[I]);
}
else
{
_distance[I] = phi_solid_nodes[mesh_l2g[eN*nDOF_mesh_trial_element+I]];
}
if ( _distance[I] >= 0)
pos_counter++;
}
if (pos_counter == 2)
{
element_active=0.0;
//std::cout<<"Identified cut cell"<<std::endl;
int opp_node=-1;
for (int I=0;I<nDOF_mesh_trial_element;I++)
{
if (_distance[I] < 0)
opp_node = I;
}
assert(opp_node >=0);
assert(opp_node <nDOF_mesh_trial_element);
}
else if (pos_counter == 3)
{
element_active=1.0;
}
else
{
element_active=0.0;
}
}
if(use_ball_as_particle==1)
{
for (int I=0;I<nDOF_mesh_trial_element;I++)
get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(),
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+0],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+1],
mesh_dof[3*mesh_l2g[eN*nDOF_mesh_trial_element+I]+2],
phi_solid_nodes[mesh_l2g[eN*nDOF_mesh_trial_element+I]]);
}
double element_phi[nDOF_mesh_trial_element], element_phi_s[nDOF_mesh_trial_element];
for (int j=0;j<nDOF_mesh_trial_element;j++)
{
register int eN_j = eN*nDOF_mesh_trial_element+j;
element_phi[j] = phi_dof[p_l2g[eN_j]];
element_phi_s[j] = phi_solid_nodes[p_l2g[eN_j]];
}
double element_nodes[nDOF_mesh_trial_element*3];
for (int i=0;i<nDOF_mesh_trial_element;i++)
{
register int eN_i=eN*nDOF_mesh_trial_element+i;
for(int I=0;I<3;I++)
element_nodes[i*3 + I] = mesh_dof[mesh_l2g[eN_i]*3 + I];
}//i
gf_s.calculate(element_phi_s, element_nodes, x_ref.data(), false);
gf.calculate(element_phi, element_nodes, x_ref.data(), false);
for (int k=0;k<nQuadraturePoints_element;k++)
{
gf.set_quad(k);
gf_s.set_quad(k);
int eN_k = eN*nQuadraturePoints_element+k, //index to a scalar at a quadrature point
eN_k_nSpace = eN_k*nSpace,
eN_k_3d = eN_k*3,
eN_nDOF_trial_element = eN*nDOF_trial_element; //index to a vector at a quadrature point
//declare local storage
register double p=0.0,u=0.0,v=0.0,w=0.0,
grad_p[nSpace],grad_u[nSpace],grad_v[nSpace],grad_w[nSpace],
hess_u[nSpace2],hess_v[nSpace2],
mom_u_acc=0.0,
dmom_u_acc_u=0.0,
mom_v_acc=0.0,
dmom_v_acc_v=0.0,
mom_w_acc=0.0,
dmom_w_acc_w=0.0,
mass_adv[nSpace],
dmass_adv_u[nSpace],
dmass_adv_v[nSpace],
dmass_adv_w[nSpace],
mom_u_adv[nSpace],
dmom_u_adv_u[nSpace],
dmom_u_adv_v[nSpace],
dmom_u_adv_w[nSpace],
mom_v_adv[nSpace],
dmom_v_adv_u[nSpace],
dmom_v_adv_v[nSpace],
dmom_v_adv_w[nSpace],
mom_w_adv[nSpace],
dmom_w_adv_u[nSpace],
dmom_w_adv_v[nSpace],
dmom_w_adv_w[nSpace],
mom_uu_diff_ten[nSpace],
mom_vv_diff_ten[nSpace],
mom_ww_diff_ten[nSpace],
mom_uv_diff_ten[1],
mom_uw_diff_ten[1],
mom_vu_diff_ten[1],
mom_vw_diff_ten[1],
mom_wu_diff_ten[1],
mom_wv_diff_ten[1],
mom_u_source=0.0,
mom_v_source=0.0,
mom_w_source=0.0,
mom_u_ham=0.0,
dmom_u_ham_grad_p[nSpace],
dmom_u_ham_grad_u[nSpace],
mom_v_ham=0.0,
dmom_v_ham_grad_p[nSpace],
dmom_v_ham_grad_v[nSpace],
mom_w_ham=0.0,
dmom_w_ham_grad_p[nSpace],
dmom_w_ham_grad_w[nSpace],
mom_u_acc_t=0.0,
dmom_u_acc_u_t=0.0,
mom_v_acc_t=0.0,
dmom_v_acc_v_t=0.0,
mom_w_acc_t=0.0,
dmom_w_acc_w_t=0.0,
pdeResidual_p=0.0,
pdeResidual_u=0.0,
pdeResidual_v=0.0,
pdeResidual_w=0.0,
dpdeResidual_p_u[nDOF_trial_element],dpdeResidual_p_v[nDOF_trial_element],dpdeResidual_p_w[nDOF_trial_element],
dpdeResidual_u_p[nDOF_trial_element],dpdeResidual_u_u[nDOF_trial_element],
dpdeResidual_v_p[nDOF_trial_element],dpdeResidual_v_v[nDOF_trial_element],
dpdeResidual_w_p[nDOF_trial_element],dpdeResidual_w_w[nDOF_trial_element],
Lstar_u_p[nDOF_test_element],
Lstar_v_p[nDOF_test_element],
Lstar_w_p[nDOF_test_element],
Lstar_u_u[nDOF_test_element],
Lstar_v_v[nDOF_test_element],
Lstar_w_w[nDOF_test_element],
Lstar_p_u[nDOF_test_element],
Lstar_p_v[nDOF_test_element],
Lstar_p_w[nDOF_test_element],
subgridError_p=0.0,
subgridError_u=0.0,
subgridError_v=0.0,
subgridError_w=0.0,
dsubgridError_p_u[nDOF_trial_element],
dsubgridError_p_v[nDOF_trial_element],
dsubgridError_p_w[nDOF_trial_element],
dsubgridError_u_p[nDOF_trial_element],
dsubgridError_u_u[nDOF_trial_element],
dsubgridError_v_p[nDOF_trial_element],
dsubgridError_v_v[nDOF_trial_element],
dsubgridError_w_p[nDOF_trial_element],
dsubgridError_w_w[nDOF_trial_element],
tau_p=0.0,tau_p0=0.0,tau_p1=0.0,
tau_v=0.0,tau_v0=0.0,tau_v1=0.0,
jac[nSpace*nSpace],
jacDet,
jacInv[nSpace*nSpace],
p_grad_trial[nDOF_trial_element*nSpace],vel_grad_trial[nDOF_trial_element*nSpace],
vel_hess_trial[nDOF_trial_element*nSpace2],
dV,
p_test_dV[nDOF_test_element],vel_test_dV[nDOF_test_element],
p_grad_test_dV[nDOF_test_element*nSpace],vel_grad_test_dV[nDOF_test_element*nSpace],
x,y,z,xt,yt,zt,
//VRANS
porosity,
//meanGrainSize,
dmom_u_source[nSpace],
dmom_v_source[nSpace],
dmom_w_source[nSpace],
mass_source,
//
G[nSpace*nSpace],G_dd_G,tr_G,h_phi, dmom_adv_star[nSpace], dmom_adv_sge[nSpace];
//get jacobian, etc for mapping reference element
ck.calculateMapping_element(eN,
k,
mesh_dof.data(),
mesh_l2g.data(),
mesh_trial_ref.data(),
mesh_grad_trial_ref.data(),
jac,
jacDet,
jacInv,
x,y,z);
ck.calculateH_element(eN,
k,
nodeDiametersArray.data(),
mesh_l2g.data(),
mesh_trial_ref.data(),
h_phi);
ck.calculateMappingVelocity_element(eN,
k,
mesh_velocity_dof.data(),
mesh_l2g.data(),
mesh_trial_ref.data(),
xt,yt,zt);
//xt=0.0;yt=0.0;zt=0.0;
//std::cout<<"xt "<<xt<<'\t'<<yt<<'\t'<<zt<<std::endl;
//get the physical integration weight
dV = fabs(jacDet)*dV_ref[k];
ck.calculateG(jacInv,G,G_dd_G,tr_G);
//ck.calculateGScale(G,&normal_phi[eN_k_nSpace],h_phi);
eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
const double particle_eps = particle_epsFact*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
//get the trial function gradients
/* ck.gradTrialFromRef(&p_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,p_grad_trial); */
ck.gradTrialFromRef(&vel_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
ck.hessTrialFromRef(&vel_hess_trial_ref[k*nDOF_trial_element*nSpace2],jacInv,vel_hess_trial);
//get the solution
/* ck.valFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],&p_trial_ref[k*nDOF_trial_element],p); */
p = q_p[eN_k];
ck.valFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],u);
ck.valFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],v);
/* ck.valFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_ref[k*nDOF_trial_element],w); */
//get the solution gradients
/* ck.gradFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],p_grad_trial,grad_p); */
for (int I=0;I<nSpace;I++)
grad_p[I] = q_grad_p[eN_k_nSpace+I];
ck.gradFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_u);
ck.gradFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_v);
ck.hessFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_hess_trial,hess_u);
ck.hessFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_hess_trial,hess_v);
/* ck.gradFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial,grad_w); */
//precalculate test function products with integration weights
for (int j=0;j<nDOF_trial_element;j++)
{
/* p_test_dV[j] = p_test_ref[k*nDOF_trial_element+j]*dV; */
vel_test_dV[j] = vel_test_ref[k*nDOF_trial_element+j]*dV;
for (int I=0;I<nSpace;I++)
{
/* p_grad_test_dV[j*nSpace+I] = p_grad_trial[j*nSpace+I]*dV;//cek warning won't work for Petrov-Galerkin */
vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;//cek warning won't work for Petrov-Galerkin}
}
}
//cek hack
double div_mesh_velocity=0.0;
int NDOF_MESH_TRIAL_ELEMENT=3;
for (int j=0;j<NDOF_MESH_TRIAL_ELEMENT;j++)
{
int eN_j=eN*NDOF_MESH_TRIAL_ELEMENT+j;
div_mesh_velocity +=
mesh_velocity_dof[mesh_l2g[eN_j]*3+0]*vel_grad_trial[j*2+0] +
mesh_velocity_dof[mesh_l2g[eN_j]*3+1]*vel_grad_trial[j*2+1];
}
div_mesh_velocity = DM3*div_mesh_velocity + (1.0-DM3)*alphaBDF*(dV-q_dV_last[eN_k])/dV;
//
//VRANS
porosity = 1.0 - q_vos[eN_k];
//
//
//calculate pde coefficients and derivatives at quadrature points
//
double distance_to_omega_solid = phi_solid[eN_k];//computed in getResidual
double eddy_viscosity(0.),rhoSave,nuSave;//not really interested in saving eddy_viscosity in jacobian
evaluateCoefficients(eps_rho,
eps_mu,
particle_eps,
sigma,
rho_0,
nu_0,
rho_1,
nu_1,
elementDiameter[eN],
smagorinskyConstant,
turbulenceClosureModel,
g.data(),
useVF,
vf[eN_k],
phi[eN_k],
&normal_phi[eN_k_nSpace],
distance_to_omega_solid,
kappa_phi[eN_k],
//VRANS
porosity,
//
p,
grad_p,
grad_u,
grad_v,
grad_w,
u,
v,
w,
q_velocity_sge[eN_k_nSpace+0],
q_velocity_sge[eN_k_nSpace+1],
q_velocity_sge[eN_k_nSpace+1],//hack, shouldn't be used
eddy_viscosity,
mom_u_acc,
dmom_u_acc_u,
mom_v_acc,
dmom_v_acc_v,
mom_w_acc,
dmom_w_acc_w,
mass_adv,
dmass_adv_u,
dmass_adv_v,
dmass_adv_w,
mom_u_adv,
dmom_u_adv_u,
dmom_u_adv_v,
dmom_u_adv_w,
mom_v_adv,
dmom_v_adv_u,
dmom_v_adv_v,
dmom_v_adv_w,
mom_w_adv,
dmom_w_adv_u,
dmom_w_adv_v,
dmom_w_adv_w,
mom_uu_diff_ten,
mom_vv_diff_ten,
mom_ww_diff_ten,
mom_uv_diff_ten,
mom_uw_diff_ten,
mom_vu_diff_ten,
mom_vw_diff_ten,
mom_wu_diff_ten,
mom_wv_diff_ten,
mom_u_source,
mom_v_source,
mom_w_source,
mom_u_ham,
dmom_u_ham_grad_p,
dmom_u_ham_grad_u,
mom_v_ham,
dmom_v_ham_grad_p,
dmom_v_ham_grad_v,
mom_w_ham,
dmom_w_ham_grad_p,
dmom_w_ham_grad_w,
rhoSave,
nuSave,
KILL_PRESSURE_TERM,
0,
0., // mql: the force term doesn't play a role in the Jacobian
0.,
0.,
MATERIAL_PARAMETERS_AS_FUNCTION,
density_as_function[eN_k],
dynamic_viscosity_as_function[eN_k],
USE_SBM,
x,y,z,
use_ball_as_particle,
ball_center.data(),
ball_radius.data(),
ball_velocity.data(),
ball_angular_velocity.data(),
INT_BY_PARTS_PRESSURE);
//VRANS
mass_source = q_mass_source[eN_k];
for (int I=0;I<nSpace;I++)
{
dmom_u_source[I] = 0.0;
dmom_v_source[I] = 0.0;
dmom_w_source[I] = 0.0;
}
updateDarcyForchheimerTerms_Ergun(/* linearDragFactor, */
/* nonlinearDragFactor, */
/* porosity, */
/* meanGrainSize, */
q_dragAlpha[eN_k],
q_dragBeta[eN_k],
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
eddy_viscosity,
useVF,
vf[eN_k],
phi[eN_k],
u,
v,
w,
q_velocity_sge[eN_k_nSpace+0],
q_velocity_sge[eN_k_nSpace+1],
q_velocity_sge[eN_k_nSpace+1],//hack, shouldn't be used
eps_solid[elementFlags[eN]],
porosity,
q_velocity_solid[eN_k_nSpace+0],
q_velocity_solid[eN_k_nSpace+1],
q_velocity_solid[eN_k_nSpace+1],//cek hack, should not be used
q_velocityStar_solid[eN_k_nSpace+0],
q_velocityStar_solid[eN_k_nSpace+1],
q_velocityStar_solid[eN_k_nSpace+1],//cek hack, should not be used
mom_u_source,
mom_v_source,
mom_w_source,
dmom_u_source,
dmom_v_source,
dmom_w_source,
q_grad_vos[eN_k_nSpace+0],
q_grad_vos[eN_k_nSpace+1],
q_grad_vos[eN_k_nSpace+1]);//cek hack, should not be used
double C_particles=0.0;
if(nParticles > 0 && USE_SBM==0)
updateSolidParticleTerms(eN < nElements_owned,
particle_nitsche,
dV,
nParticles,
nQuadraturePoints_global,
&particle_signed_distances[eN_k],
&particle_signed_distance_normals[eN_k_3d],
&particle_velocities[eN_k_3d],
particle_centroids.data(),
use_ball_as_particle,
ball_center.data(),
ball_radius.data(),
ball_velocity.data(),
ball_angular_velocity.data(),
porosity,
particle_penalty_constant/h_phi,
particle_alpha/h_phi,
particle_beta/h_phi,
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
useVF,
vf[eN_k],
phi[eN_k],
x,
y,
z,
p,
u,
v,
w,
q_velocity_sge[eN_k_nSpace+0],
q_velocity_sge[eN_k_nSpace+1],
q_velocity_sge[eN_k_nSpace+1],
particle_eps,
grad_u,
grad_v,
grad_w,
mom_u_source,
mom_v_source,
mom_w_source,
dmom_u_source,
dmom_v_source,
dmom_w_source,
mom_u_adv,
mom_v_adv,
mom_w_adv,
dmom_u_adv_u,
dmom_v_adv_v,
dmom_w_adv_w,
mom_u_ham,
dmom_u_ham_grad_u,
mom_v_ham,
dmom_v_ham_grad_v,
mom_w_ham,
dmom_w_ham_grad_w,
&particle_netForces[0],
&particle_netMoments[0],
&particle_surfaceArea[0]);
//Turbulence closure model
if (turbulenceClosureModel >= 3)
{
const double c_mu = 0.09;//mwf hack
updateTurbulenceClosure(turbulenceClosureModel,
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
useVF,
vf[eN_k],
phi[eN_k],
porosity,
c_mu, //mwf hack
q_turb_var_0[eN_k],
q_turb_var_1[eN_k],
&q_turb_var_grad_0[eN_k_nSpace],
eddy_viscosity,
mom_uu_diff_ten,
mom_vv_diff_ten,
mom_ww_diff_ten,
mom_uv_diff_ten,
mom_uw_diff_ten,
mom_vu_diff_ten,
mom_vw_diff_ten,
mom_wu_diff_ten,
mom_wv_diff_ten,
mom_u_source,
mom_v_source,
mom_w_source);
}
//
//
//moving mesh
//
mom_u_adv[0] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*xt; // multiply by rho*porosity. mql. CHECK.
mom_u_adv[1] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*yt;
/* mom_u_adv[2] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*zt; */
dmom_u_adv_u[0] -= MOVING_DOMAIN*dmom_u_acc_u*xt;
dmom_u_adv_u[1] -= MOVING_DOMAIN*dmom_u_acc_u*yt;
/* dmom_u_adv_u[2] -= MOVING_DOMAIN*dmom_u_acc_u*zt; */
mom_v_adv[0] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*xt;
mom_v_adv[1] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*yt;
/* mom_v_adv[2] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*zt; */
dmom_v_adv_v[0] -= MOVING_DOMAIN*dmom_v_acc_v*xt;
dmom_v_adv_v[1] -= MOVING_DOMAIN*dmom_v_acc_v*yt;
/* dmom_v_adv_v[2] -= MOVING_DOMAIN*dmom_v_acc_v*zt; */
/* mom_w_adv[0] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*xt; */
/* mom_w_adv[1] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*yt; */
/* mom_w_adv[2] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*zt; */
/* dmom_w_adv_w[0] -= MOVING_DOMAIN*dmom_w_acc_w*xt; */
/* dmom_w_adv_w[1] -= MOVING_DOMAIN*dmom_w_acc_w*yt; */
/* dmom_w_adv_w[2] -= MOVING_DOMAIN*dmom_w_acc_w*zt; */
//
//calculate time derivatives
//
ck.bdf(alphaBDF,
q_mom_u_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV,
mom_u_acc,
dmom_u_acc_u,
mom_u_acc_t,
dmom_u_acc_u_t);
ck.bdf(alphaBDF,
q_mom_v_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV,
mom_v_acc,
dmom_v_acc_v,
mom_v_acc_t,
dmom_v_acc_v_t);
/* ck.bdf(alphaBDF, */
/* q_mom_w_acc_beta_bdf[eN_k]*q_dV_last[eN_k]/dV, */
/* mom_w_acc, */
/* dmom_w_acc_w, */
/* mom_w_acc_t, */
/* dmom_w_acc_w_t); */
//
//calculate subgrid error contribution to the Jacobian (strong residual, adjoint, jacobian of strong residual)
mom_u_acc_t *= dmom_u_acc_u; //multiply by porosity*rho. mql. CHECK.
mom_v_acc_t *= dmom_v_acc_v;
//
dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt);
dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt);
/* dmom_adv_sge[2] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+2] - MOVING_DOMAIN*zt); */
//
//calculate strong residual
//
pdeResidual_p =
ck.Mass_strong(-q_dvos_dt[eN_k]) + // mql. CHECK.
ck.Advection_strong(dmass_adv_u,grad_u) +
ck.Advection_strong(dmass_adv_v,grad_v) +
/* ck.Advection_strong(dmass_adv_w,grad_w) + */
DM2*MOVING_DOMAIN*ck.Reaction_strong(alphaBDF*(dV-q_dV_last[eN_k])/dV - div_mesh_velocity) +
//VRANS
ck.Reaction_strong(mass_source);
//
pdeResidual_u =
ck.Mass_strong(mom_u_acc_t) +
ck.Advection_strong(dmom_adv_sge,grad_u) +
ck.Hamiltonian_strong(dmom_u_ham_grad_p,grad_p) +
ck.Reaction_strong(mom_u_source) -
ck.Reaction_strong(u*div_mesh_velocity);
pdeResidual_v =
ck.Mass_strong(mom_v_acc_t) +
ck.Advection_strong(dmom_adv_sge,grad_v) +
ck.Hamiltonian_strong(dmom_v_ham_grad_p,grad_p) +
ck.Reaction_strong(mom_v_source) -
ck.Reaction_strong(v*div_mesh_velocity);
/* pdeResidual_w =
ck.Mass_strong(mom_w_acc_t) + */
/* ck.Advection_strong(dmom_adv_sge,grad_w) + */
/* ck.Hamiltonian_strong(dmom_w_ham_grad_p,grad_p) + */
/* ck.Reaction_strong(mom_w_source) - */
/* ck.Reaction_strong(w*div_mesh_velocity); */
//calculate the Jacobian of strong residual
for (int j=0;j<nDOF_trial_element;j++)
{
register int j_nSpace = j*nSpace;
dpdeResidual_p_u[j]=ck.AdvectionJacobian_strong(dmass_adv_u,&vel_grad_trial[j_nSpace]);
dpdeResidual_p_v[j]=ck.AdvectionJacobian_strong(dmass_adv_v,&vel_grad_trial[j_nSpace]);
/* dpdeResidual_p_w[j]=ck.AdvectionJacobian_strong(dmass_adv_w,&vel_grad_trial[j_nSpace]); */
dpdeResidual_u_p[j]=ck.HamiltonianJacobian_strong(dmom_u_ham_grad_p,&p_grad_trial[j_nSpace]);
dpdeResidual_u_u[j]=ck.MassJacobian_strong(dmom_u_acc_u_t,vel_trial_ref[k*nDOF_trial_element+j]) +
ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) -
ck.ReactionJacobian_strong(div_mesh_velocity,vel_trial_ref[k*nDOF_trial_element+j]);
dpdeResidual_v_p[j]=ck.HamiltonianJacobian_strong(dmom_v_ham_grad_p,&p_grad_trial[j_nSpace]);
dpdeResidual_v_v[j]=ck.MassJacobian_strong(dmom_v_acc_v_t,vel_trial_ref[k*nDOF_trial_element+j]) +
ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) -
ck.ReactionJacobian_strong(div_mesh_velocity,vel_trial_ref[k*nDOF_trial_element+j]);
/* dpdeResidual_w_p[j]=ck.HamiltonianJacobian_strong(dmom_w_ham_grad_p,&p_grad_trial[j_nSpace]); */
/* dpdeResidual_w_w[j]=ck.MassJacobian_strong(dmom_w_acc_w_t,vel_trial_ref[k*nDOF_trial_element+j]) + */
/* ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) -
ck.ReactionJacobian_strong(div_mesh_velocity,vel_trial_ref[k*nDOF_trial_element+j]); */
//VRANS account for drag terms, diagonal only here ... decide if need off diagonal terms too
dpdeResidual_u_u[j]+= ck.ReactionJacobian_strong(dmom_u_source[0],vel_trial_ref[k*nDOF_trial_element+j]);
dpdeResidual_v_v[j]+= ck.ReactionJacobian_strong(dmom_v_source[1],vel_trial_ref[k*nDOF_trial_element+j]);
/* dpdeResidual_w_w[j]+= ck.ReactionJacobian_strong(dmom_w_source[2],vel_trial_ref[k*nDOF_trial_element+j]); */
//
}
//calculate tau and tau*Res
//cek debug
double tmpR=dmom_u_acc_u_t + dmom_u_source[0];
calculateSubgridError_tau(hFactor,
elementDiameter[eN],
tmpR,//dmom_u_acc_u_t,
dmom_u_acc_u,
dmom_adv_sge,
mom_uu_diff_ten[1],
dmom_u_ham_grad_p[0],
tau_v0,
tau_p0,
q_cfl[eN_k]);
calculateSubgridError_tau(Ct_sge,Cd_sge,
G,G_dd_G,tr_G,
tmpR,//dmom_u_acc_u_t,
dmom_adv_sge,
mom_uu_diff_ten[1],
dmom_u_ham_grad_p[0],
tau_v1,
tau_p1,
q_cfl[eN_k]);
tau_v = useMetrics*tau_v1+(1.0-useMetrics)*tau_v0;
tau_p = KILL_PRESSURE_TERM == 1 ? 0. : PSTAB*(useMetrics*tau_p1+(1.0-useMetrics)*tau_p0);
calculateSubgridError_tauRes(tau_p,
tau_v,
pdeResidual_p,
pdeResidual_u,
pdeResidual_v,
pdeResidual_w,
subgridError_p,
subgridError_u,
subgridError_v,
subgridError_w);
calculateSubgridErrorDerivatives_tauRes(tau_p,
tau_v,
dpdeResidual_p_u,
dpdeResidual_p_v,
dpdeResidual_p_w,
dpdeResidual_u_p,
dpdeResidual_u_u,
dpdeResidual_v_p,
dpdeResidual_v_v,
dpdeResidual_w_p,
dpdeResidual_w_w,
dsubgridError_p_u,
dsubgridError_p_v,
dsubgridError_p_w,
dsubgridError_u_p,
dsubgridError_u_u,
dsubgridError_v_p,
dsubgridError_v_v,
dsubgridError_w_p,
dsubgridError_w_w);
// velocity used in adjoint (VMS or RBLES, with or without lagging the grid scale velocity)
dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+0] - MOVING_DOMAIN*xt + useRBLES*subgridError_u);
dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v);
/* dmom_adv_star[2] = dmom_u_acc_u*(q_velocity_sge[eN_k_nSpace+2] - MOVING_DOMAIN*zt + useRBLES*subgridError_w); */
//calculate the adjoint times the test functions
for (int i=0;i<nDOF_test_element;i++)
{
register int i_nSpace = i*nSpace;
Lstar_u_p[i]=ck.Advection_adjoint(dmass_adv_u,&p_grad_test_dV[i_nSpace]);
Lstar_v_p[i]=ck.Advection_adjoint(dmass_adv_v,&p_grad_test_dV[i_nSpace]);
/* Lstar_w_p[i]=ck.Advection_adjoint(dmass_adv_w,&p_grad_test_dV[i_nSpace]); */
Lstar_u_u[i]=ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
Lstar_v_v[i]=ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
/* Lstar_w_w[i]=ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]); */
Lstar_p_u[i]=ck.Hamiltonian_adjoint(dmom_u_ham_grad_p,&vel_grad_test_dV[i_nSpace]);
Lstar_p_v[i]=ck.Hamiltonian_adjoint(dmom_v_ham_grad_p,&vel_grad_test_dV[i_nSpace]);
/* Lstar_p_w[i]=ck.Hamiltonian_adjoint(dmom_w_ham_grad_p,&vel_grad_test_dV[i_nSpace]); */
//VRANS account for drag terms, diagonal only here ... decide if need off diagonal terms too
Lstar_u_u[i]+=ck.Reaction_adjoint(dmom_u_source[0],vel_test_dV[i]);
Lstar_v_v[i]+=ck.Reaction_adjoint(dmom_v_source[1],vel_test_dV[i]);
/* Lstar_w_w[i]+=ck.Reaction_adjoint(dmom_w_source[2],vel_test_dV[i]); */
}
// Assumes non-lagged subgrid velocity
dmom_u_adv_u[0] += dmom_u_acc_u*(useRBLES*subgridError_u);
dmom_u_adv_u[1] += dmom_u_acc_u*(useRBLES*subgridError_v);
/* dmom_u_adv_u[2] += dmom_u_acc_u*(useRBLES*subgridError_w); */
dmom_v_adv_v[0] += dmom_u_acc_u*(useRBLES*subgridError_u);
dmom_v_adv_v[1] += dmom_u_acc_u*(useRBLES*subgridError_v);
/* dmom_v_adv_v[2] += dmom_u_acc_u*(useRBLES*subgridError_w); */
/* dmom_w_adv_w[0] += dmom_u_acc_u*(useRBLES*subgridError_u); */
/* dmom_w_adv_w[1] += dmom_u_acc_u*(useRBLES*subgridError_v); */
/* dmom_w_adv_w[2] += dmom_u_acc_u*(useRBLES*subgridError_w); */
// SURFACE TENSION //
double unit_normal[nSpace];
double norm_grad_phi = 0.;
for (int I=0;I<nSpace;I++)
norm_grad_phi += normal_phi[eN_k_nSpace+I]*normal_phi[eN_k_nSpace+I];
norm_grad_phi = std::sqrt(norm_grad_phi) + 1E-10;
for (int I=0;I<nSpace;I++)
unit_normal[I] = normal_phi[eN_k_nSpace+I]/norm_grad_phi;
double delta = gf.D(eps_mu,phi[eN_k]); //use eps_rho instead?
register double vel_tgrad_test_i[nSpace], vel_tgrad_test_j[nSpace];
// END OF SURFACE TENSION //
//cek todo add RBLES terms consistent to residual modifications or ignore the partials w.r.t the additional RBLES terms
for(int i=0;i<nDOF_test_element;i++)
{
register int i_nSpace = i*nSpace;
calculateTangentialGradient(unit_normal,
&vel_grad_trial[i_nSpace],
vel_tgrad_test_i);
for(int j=0;j<nDOF_trial_element;j++)
{
register int j_nSpace = j*nSpace;
calculateTangentialGradient(unit_normal,
&vel_grad_trial[j_nSpace],
vel_tgrad_test_j);
/* elementJacobian_p_p[i][j] += ck.SubgridErrorJacobian(dsubgridError_u_p[j],Lstar_u_p[i]) + */
/* ck.SubgridErrorJacobian(dsubgridError_v_p[j],Lstar_v_p[i]);// + */
/* /\* ck.SubgridErrorJacobian(dsubgridError_w_p[j],Lstar_w_p[i]); *\/ */
/* elementJacobian_p_u[i][j] += ck.AdvectionJacobian_weak(dmass_adv_u,vel_trial_ref[k*nDOF_trial_element+j],&p_grad_test_dV[i_nSpace]) + */
/* ck.SubgridErrorJacobian(dsubgridError_u_u[j],Lstar_u_p[i]); */
/* elementJacobian_p_v[i][j] += ck.AdvectionJacobian_weak(dmass_adv_v,vel_trial_ref[k*nDOF_trial_element+j],&p_grad_test_dV[i_nSpace]) + */
/* ck.SubgridErrorJacobian(dsubgridError_v_v[j],Lstar_v_p[i]); */
/* elementJacobian_p_w[i][j] += ck.AdvectionJacobian_weak(dmass_adv_w,vel_trial_ref[k*nDOF_trial_element+j],&p_grad_test_dV[i_nSpace]) + */
/* ck.SubgridErrorJacobian(dsubgridError_w_w[j],Lstar_w_p[i]); */
/* elementJacobian_u_p[i][j] += ck.HamiltonianJacobian_weak(dmom_u_ham_grad_p,&p_grad_trial[j_nSpace],vel_test_dV[i]) + */
/* ck.SubgridErrorJacobian(dsubgridError_u_p[j],Lstar_u_u[i]); */
elementJacobian_u_u[i][j] +=
ck.MassJacobian_weak(dmom_u_acc_u_t,vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) +
ck.HamiltonianJacobian_weak(dmom_u_ham_grad_u,&vel_grad_trial[j_nSpace],vel_test_dV[i]) +
ck.AdvectionJacobian_weak(dmom_u_adv_u,vel_trial_ref[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
ck.SimpleDiffusionJacobian_weak(sdInfo_u_u_rowptr.data(),sdInfo_u_u_colind.data(),mom_uu_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
//VRANS
ck.ReactionJacobian_weak(dmom_u_source[0],vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) +
//
//ck.SubgridErrorJacobian(dsubgridError_p_u[j],Lstar_p_u[i]) +
USE_SUPG*ck.SubgridErrorJacobian(dsubgridError_u_u[j],Lstar_u_u[i]) +
ck.NumericalDiffusionJacobian(q_numDiff_u_last[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
// surface tension
ck.NumericalDiffusion(dt*delta*sigma*dV,
vel_tgrad_test_i,
vel_tgrad_test_j);
elementJacobian_u_v[i][j] +=
ck.AdvectionJacobian_weak(dmom_u_adv_v,vel_trial_ref[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
ck.SimpleDiffusionJacobian_weak(sdInfo_u_v_rowptr.data(),sdInfo_u_v_colind.data(),mom_uv_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
//VRANS
ck.ReactionJacobian_weak(dmom_u_source[1],vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i])
//+ck.SubgridErrorJacobian(dsubgridError_p_v[j],Lstar_p_u[i])
;
/* elementJacobian_u_w[i][j] += ck.AdvectionJacobian_weak(dmom_u_adv_w,vel_trial_ref[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) + */
/* ck.SimpleDiffusionJacobian_weak(sdInfo_u_w_rowptr,sdInfo_u_w_colind,mom_uw_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) + */
/* //VRANS */
/* ck.ReactionJacobian_weak(dmom_u_source[2],vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) + */
/* // */
/* ck.SubgridErrorJacobian(dsubgridError_p_w[j],Lstar_p_u[i]); */
/* elementJacobian_v_p[i][j] += ck.HamiltonianJacobian_weak(dmom_v_ham_grad_p,&p_grad_trial[j_nSpace],vel_test_dV[i]) + */
/* ck.SubgridErrorJacobian(dsubgridError_v_p[j],Lstar_v_v[i]); */
elementJacobian_v_u[i][j] +=
ck.AdvectionJacobian_weak(dmom_v_adv_u,vel_trial_ref[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
ck.SimpleDiffusionJacobian_weak(sdInfo_v_u_rowptr.data(),sdInfo_v_u_colind.data(),mom_vu_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
//VRANS
ck.ReactionJacobian_weak(dmom_v_source[0],vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i])
//+ck.SubgridErrorJacobian(dsubgridError_p_u[j],Lstar_p_v[i])
;
elementJacobian_v_v[i][j] +=
ck.MassJacobian_weak(dmom_v_acc_v_t,vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) +
ck.HamiltonianJacobian_weak(dmom_v_ham_grad_v,&vel_grad_trial[j_nSpace],vel_test_dV[i]) +
ck.AdvectionJacobian_weak(dmom_v_adv_v,vel_trial_ref[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
ck.SimpleDiffusionJacobian_weak(sdInfo_v_v_rowptr.data(),sdInfo_v_v_colind.data(),mom_vv_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
//VRANS
ck.ReactionJacobian_weak(dmom_v_source[1],vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) +
//
//ck.SubgridErrorJacobian(dsubgridError_p_v[j],Lstar_p_v[i]) +
USE_SUPG*ck.SubgridErrorJacobian(dsubgridError_v_v[j],Lstar_v_v[i]) +
ck.NumericalDiffusionJacobian(q_numDiff_v_last[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
// surface tension
ck.NumericalDiffusion(dt*delta*sigma*dV,
vel_tgrad_test_i,
vel_tgrad_test_j);
/* elementJacobian_v_w[i][j] += ck.AdvectionJacobian_weak(dmom_v_adv_w,vel_trial_ref[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) + */
/* ck.SimpleDiffusionJacobian_weak(sdInfo_v_w_rowptr,sdInfo_v_w_colind,mom_vw_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) + */
/* //VRANS */
/* ck.ReactionJacobian_weak(dmom_v_source[2],vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) + */
/* // */
/* ck.SubgridErrorJacobian(dsubgridError_p_w[j],Lstar_p_v[i]); */
/* elementJacobian_w_p[i][j] += ck.HamiltonianJacobian_weak(dmom_w_ham_grad_p,&p_grad_trial[j_nSpace],vel_test_dV[i]) + */
/* ck.SubgridErrorJacobian(dsubgridError_w_p[j],Lstar_w_w[i]); */
/* elementJacobian_w_u[i][j] += ck.AdvectionJacobian_weak(dmom_w_adv_u,vel_trial_ref[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) + */
/* ck.SimpleDiffusionJacobian_weak(sdInfo_w_u_rowptr,sdInfo_w_u_colind,mom_wu_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) + */
/* //VRANS */
/* ck.ReactionJacobian_weak(dmom_w_source[0],vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) + */
/* // */
/* ck.SubgridErrorJacobian(dsubgridError_p_u[j],Lstar_p_w[i]); */
/* elementJacobian_w_v[i][j] += ck.AdvectionJacobian_weak(dmom_w_adv_v,vel_trial_ref[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) + */
/* ck.SimpleDiffusionJacobian_weak(sdInfo_w_v_rowptr,sdInfo_w_v_colind,mom_wv_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) + */
/* //VRANS */
/* ck.ReactionJacobian_weak(dmom_w_source[1],vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) + */
/* // */
/* ck.SubgridErrorJacobian(dsubgridError_p_v[j],Lstar_p_w[i]); */
/* elementJacobian_w_w[i][j] += ck.MassJacobian_weak(dmom_w_acc_w_t,vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) + */
/* ck.HamiltonianJacobian_weak(dmom_w_ham_grad_w,&vel_grad_trial[j_nSpace],vel_test_dV[i]) + */
/* ck.AdvectionJacobian_weak(dmom_w_adv_w,vel_trial_ref[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) + */
/* ck.SimpleDiffusionJacobian_weak(sdInfo_w_w_rowptr,sdInfo_w_w_colind,mom_ww_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) + */
/* //VRANS */
/* ck.ReactionJacobian_weak(dmom_w_source[2],vel_trial_ref[k*nDOF_trial_element+j],vel_test_dV[i]) + */
/* // */
/* ck.SubgridErrorJacobian(dsubgridError_p_w[j],Lstar_p_w[i]) + */
/* ck.SubgridErrorJacobian(dsubgridError_w_w[j],Lstar_w_w[i]) + */
/* ck.NumericalDiffusionJacobian(q_numDiff_w_last[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]); */
}//j
}//i
}//k
//
//load into element Jacobian into global Jacobian
//
for (int i=0;i<nDOF_test_element;i++)
{
register int eN_i = eN*nDOF_test_element+i;
for (int j=0;j<nDOF_trial_element;j++)
{
register int eN_i_j = eN_i*nDOF_trial_element+j;
/* globalJacobian[csrRowIndeces_p_p[eN_i] + csrColumnOffsets_p_p[eN_i_j]] += elementJacobian_p_p[i][j]; */
/* globalJacobian[csrRowIndeces_p_u[eN_i] + csrColumnOffsets_p_u[eN_i_j]] += elementJacobian_p_u[i][j]; */
/* globalJacobian[csrRowIndeces_p_v[eN_i] + csrColumnOffsets_p_v[eN_i_j]] += elementJacobian_p_v[i][j]; */
/* globalJacobian[csrRowIndeces_p_w[eN_i] + csrColumnOffsets_p_w[eN_i_j]] += elementJacobian_p_w[i][j]; */
/* globalJacobian[csrRowIndeces_u_p[eN_i] + csrColumnOffsets_u_p[eN_i_j]] += elementJacobian_u_p[i][j]; */
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_u_u[eN_i_j]] += element_active*elementJacobian_u_u[i][j];
globalJacobian[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_u_v[eN_i_j]] += element_active*elementJacobian_u_v[i][j];
/* globalJacobian[csrRowIndeces_u_w[eN_i] + csrColumnOffsets_u_w[eN_i_j]] += elementJacobian_u_w[i][j]; */
/* globalJacobian[csrRowIndeces_v_p[eN_i] + csrColumnOffsets_v_p[eN_i_j]] += elementJacobian_v_p[i][j]; */
globalJacobian[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_v_u[eN_i_j]] += element_active*elementJacobian_v_u[i][j];
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_v_v[eN_i_j]] += element_active*elementJacobian_v_v[i][j];
/* globalJacobian[csrRowIndeces_v_w[eN_i] + csrColumnOffsets_v_w[eN_i_j]] += elementJacobian_v_w[i][j]; */
/* globalJacobian[csrRowIndeces_w_p[eN_i] + csrColumnOffsets_w_p[eN_i_j]] += elementJacobian_w_p[i][j]; */
/* globalJacobian[csrRowIndeces_w_u[eN_i] + csrColumnOffsets_w_u[eN_i_j]] += elementJacobian_w_u[i][j]; */
/* globalJacobian[csrRowIndeces_w_v[eN_i] + csrColumnOffsets_w_v[eN_i_j]] += elementJacobian_w_v[i][j]; */
/* globalJacobian[csrRowIndeces_w_w[eN_i] + csrColumnOffsets_w_w[eN_i_j]] += elementJacobian_w_w[i][j]; */
}//j
}//i
}//elements
// loop in DOFs for discrete upwinding
if (ARTIFICIAL_VISCOSITY==3 || ARTIFICIAL_VISCOSITY==4)
{
int ij=0;
for (int i=0; i<numDOFs_1D; i++)
{
// global index for each component
int u_gi = offset_u+stride_u*i;
int v_gi = offset_v+stride_v*i;
// pointer to first entry in the ith row for each component
int u_ith_row_ptr = rowptr[u_gi];
int v_ith_row_ptr = rowptr[v_gi];
// number of DOFs in the ith row (of the small matrix dMatrix)
int numDOFs_ith_row = rowptr_1D[i+1]-rowptr_1D[i];
for (int counter = 0; counter < numDOFs_ith_row; counter++)
{
// ij pointer for each component
int uu_ij = u_ith_row_ptr + (offset_u + counter*stride_u);
int vv_ij = v_ith_row_ptr + (offset_v + counter*stride_v);
// read ij component of dissipative matrix
double uStar_dij = uStar_dMatrix[ij];
double vStar_dij = vStar_dMatrix[ij];
// update global Jacobian
globalJacobian[uu_ij] -= uStar_dij;
globalJacobian[vv_ij] -= vStar_dij;
// update ij
ij++;
}
}
}
if(USE_SBM>0)
{
//loop over the surrogate boundaries in SB method and assembly into jacobian
//
for (int ebN_s=0;ebN_s < surrogate_boundaries.size();ebN_s++)
{
register int ebN = surrogate_boundaries[ebN_s],
eN = elementBoundaryElementsArray[ebN*2+surrogate_boundary_elements[ebN_s]],
ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+surrogate_boundary_elements[ebN_s]],
eN_nDOF_trial_element = eN*nDOF_trial_element;
register double eps_rho,eps_mu;
//This assumption is wrong for parallel: If one of nodes of this edge is owned by this processor,
//then the integral over this edge has contribution to the residual and Jacobian.
//if (ebN >= nElementBoundaries_owned) continue;
for (int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
{
register int ebN_kb = ebN*nQuadraturePoints_elementBoundary+kb,
ebN_kb_nSpace = ebN_kb*nSpace,
ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
ebN_local_kb_nSpace = ebN_local_kb*nSpace;
register double u_ext=0.0,
v_ext=0.0,
bc_u_ext=0.0,
bc_v_ext=0.0,
grad_u_ext[nSpace],
grad_v_ext[nSpace],
jac_ext[nSpace*nSpace],
jacDet_ext,
jacInv_ext[nSpace*nSpace],
boundaryJac[nSpace*(nSpace-1)],
metricTensor[(nSpace-1)*(nSpace-1)],
metricTensorDetSqrt,
vel_grad_trial_trace[nDOF_trial_element*nSpace],
dS,
vel_test_dS[nDOF_test_element],
normal[2],
x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
vel_grad_test_dS[nDOF_trial_element*nSpace],
G[nSpace*nSpace],G_dd_G,tr_G,h_phi,h_penalty,penalty;
ck.calculateMapping_elementBoundary(eN,
ebN_local,
kb,
ebN_local_kb,
mesh_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
mesh_grad_trial_trace_ref.data(),
boundaryJac_ref.data(),
jac_ext,
jacDet_ext,
jacInv_ext,
boundaryJac,
metricTensor,
metricTensorDetSqrt,
normal_ref.data(),
normal,
x_ext,y_ext,z_ext);
ck.calculateMappingVelocity_elementBoundary(eN,
ebN_local,
kb,
ebN_local_kb,
mesh_velocity_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
xt_ext,yt_ext,zt_ext,
normal,
boundaryJac,
metricTensor,
integralScaling);
dS = metricTensorDetSqrt*dS_ref[kb];
ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
//compute shape and solution information
//shape
ck.gradTrialFromRef(&vel_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,vel_grad_trial_trace);
//solution and gradients
ck.valFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext);
ck.valFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],v_ext);
ck.gradFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_u_ext);
ck.gradFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_v_ext);
//precalculate test function products with integration weights
for (int j=0;j<nDOF_trial_element;j++)
{
vel_test_dS[j] = vel_test_trace_ref[ebN_local_kb*nDOF_test_element+j]*dS;
for (int I=0;I<nSpace;I++)
vel_grad_test_dS[j*nSpace+I] = vel_grad_trial_trace[j*nSpace+I]*dS;
}
//
//load the boundary values
//
bc_u_ext = 0.0;
bc_v_ext = 0.0;
ck.calculateGScale(G,normal,h_penalty);
//
//update the global Jacobian from the flux Jacobian
//
double dist = 0.0;
double distance[2], P_normal[2], P_tangent[2]; // distance vector, normal and tangent of the physical boundary
if(use_ball_as_particle==1)
{
get_distance_to_ball(nParticles,ball_center.data(),ball_radius.data(),
x_ext,y_ext,z_ext,
dist);
get_normal_to_ith_ball(nParticles,ball_center.data(),ball_radius.data(),
surrogate_boundary_particle[ebN_s],
x_ext,y_ext,z_ext,
P_normal[0],P_normal[1]);
get_velocity_to_ith_ball(nParticles,ball_center.data(),ball_radius.data(),
ball_velocity.data(), ball_angular_velocity.data(),
surrogate_boundary_particle[ebN_s],
x_ext-dist*P_normal[0],
y_ext-dist*P_normal[1],
0.0,//z_ext,
bc_u_ext,bc_v_ext);
}
else
{
dist = ebq_global_phi_solid[ebN_kb];
P_normal[0] = ebq_global_grad_phi_solid[ebN_kb*3+0];
P_normal[1] = ebq_global_grad_phi_solid[ebN_kb*3+1];
bc_u_ext = ebq_particle_velocity_solid [ebN_kb*3+0];
bc_v_ext = ebq_particle_velocity_solid [ebN_kb*3+1];
}
distance[0] = -P_normal[0]*dist;//distance=vector from \tilde{x} to x. It holds also when dist<0.0
distance[1] = -P_normal[1]*dist;
P_tangent[0]= -P_normal[1];
P_tangent[1]= P_normal[0];
assert(h_penalty>0.0);
if (h_penalty < std::abs(dist))
h_penalty = std::abs(dist);
//hack: this won't work for two-phase flow, need mixture viscosity
double visco = nu_0*rho_0;
double C_adim = C_sbm*visco/h_penalty;
double beta_adim = beta_sbm*visco/h_penalty;
for (int i=0;i<nDOF_test_element;i++)
{
register int eN_i = eN*nDOF_test_element+i;
double phi_i = vel_test_dS[i];
double* grad_phi_i = &vel_grad_test_dS[i*nSpace+0];
const double grad_phi_i_dot_d = get_dot_product(grad_phi_i,distance);
const double grad_phi_i_dot_t = get_dot_product(P_tangent,grad_phi_i);
double res[2];
const double zero_vec[2]={0.,0.};
for (int j=0;j<nDOF_trial_element;j++)
{
register int ebN_i_j = ebN*4*nDOF_test_X_trial_element
+ surrogate_boundary_elements[ebN_s]*2*nDOF_test_X_trial_element
+ surrogate_boundary_elements[ebN_s]*nDOF_test_X_trial_element
+ i*nDOF_trial_element
+ j;
double phi_j = vel_test_dS[j]/dS;
const double grad_phi_j[2]={vel_grad_test_dS[j*nSpace+0]/dS,
vel_grad_test_dS[j*nSpace+1]/dS};
const double grad_phi_j_dot_d = get_dot_product(distance, grad_phi_j);
const double grad_phi_j_dot_t = get_dot_product(P_tangent,grad_phi_j);
// Classical Nitsche
// (1)
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] +=
phi_i*phi_j*C_adim;
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] +=
phi_i*phi_j*C_adim;
// (2)
get_symmetric_gradient_dot_vec(grad_phi_j,zero_vec,normal,res);
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] -=
visco * phi_i * res[0];
globalJacobian[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_eb_u_v[ebN_i_j]] -=
visco * phi_i * res[1];
get_symmetric_gradient_dot_vec(zero_vec,grad_phi_j,normal,res);
globalJacobian[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_eb_v_u[ebN_i_j]] -=
visco * phi_i * res[0];
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] -=
visco * phi_i * res[1];
// (3)
get_symmetric_gradient_dot_vec(grad_phi_i,zero_vec,normal,res);
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] -=
visco * phi_j * res[0];
globalJacobian[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_eb_u_v[ebN_i_j]] -=
visco * phi_j * res[1];
get_symmetric_gradient_dot_vec(zero_vec,grad_phi_i,normal,res);
globalJacobian[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_eb_v_u[ebN_i_j]] -=
visco * phi_j * res[0];
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] -=
visco * phi_j * res[1];
// (4)
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] +=
C_adim*grad_phi_i_dot_d*phi_j;
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] +=
C_adim*grad_phi_i_dot_d*phi_j;
// (5)
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] +=
C_adim*grad_phi_i_dot_d*grad_phi_j_dot_d;
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] +=
C_adim*grad_phi_i_dot_d*grad_phi_j_dot_d;
// (6)
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] +=
C_adim*grad_phi_j_dot_d*phi_i;
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] +=
C_adim*grad_phi_j_dot_d*phi_i;
// (7)
get_symmetric_gradient_dot_vec(grad_phi_i,zero_vec,normal,res);
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] -=
visco * grad_phi_j_dot_d * res[0];
globalJacobian[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_eb_u_v[ebN_i_j]] -=
visco * grad_phi_j_dot_d * res[1];
get_symmetric_gradient_dot_vec(zero_vec,grad_phi_i,normal,res);
globalJacobian[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_eb_v_u[ebN_i_j]] -=
visco * grad_phi_j_dot_d * res[0] ;
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] -=
visco * grad_phi_j_dot_d * res[1];
// (8)
// the penalization on the tangential derivative
// B < Gw t , (Gu - GuD) t >
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] +=
beta_adim*grad_phi_j_dot_t*grad_phi_i_dot_t;
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] +=
beta_adim*grad_phi_j_dot_t*grad_phi_i_dot_t;
}//j
}//i
}//kb
}//ebN_s
}
//
//loop over exterior element boundaries to compute the surface integrals and load them into the global Jacobian
//
//exact generalized function integration not implemented for boundaries yet
gf.useExact=false;
gf_s.useExact=false;
for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
{
register int ebN = exteriorElementBoundariesArray[ebNE],
eN = elementBoundaryElementsArray[ebN*2+0],
eN_nDOF_trial_element = eN*nDOF_trial_element,
ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
register double eps_rho,eps_mu;
for (int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
{
register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
ebNE_kb_nSpace = ebNE_kb*nSpace,
ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
ebN_local_kb_nSpace = ebN_local_kb*nSpace;
register double p_ext=0.0,
u_ext=0.0,
v_ext=0.0,
w_ext=0.0,
grad_p_ext[nSpace],
grad_u_ext[nSpace],
grad_v_ext[nSpace],
grad_w_ext[nSpace],
mom_u_acc_ext=0.0,
dmom_u_acc_u_ext=0.0,
mom_v_acc_ext=0.0,
dmom_v_acc_v_ext=0.0,
mom_w_acc_ext=0.0,
dmom_w_acc_w_ext=0.0,
mass_adv_ext[nSpace],
dmass_adv_u_ext[nSpace],
dmass_adv_v_ext[nSpace],
dmass_adv_w_ext[nSpace],
mom_u_adv_ext[nSpace],
dmom_u_adv_u_ext[nSpace],
dmom_u_adv_v_ext[nSpace],
dmom_u_adv_w_ext[nSpace],
mom_v_adv_ext[nSpace],
dmom_v_adv_u_ext[nSpace],
dmom_v_adv_v_ext[nSpace],
dmom_v_adv_w_ext[nSpace],
mom_w_adv_ext[nSpace],
dmom_w_adv_u_ext[nSpace],
dmom_w_adv_v_ext[nSpace],
dmom_w_adv_w_ext[nSpace],
mom_uu_diff_ten_ext[nSpace],
mom_vv_diff_ten_ext[nSpace],
mom_ww_diff_ten_ext[nSpace],
mom_uv_diff_ten_ext[1],
mom_uw_diff_ten_ext[1],
mom_vu_diff_ten_ext[1],
mom_vw_diff_ten_ext[1],
mom_wu_diff_ten_ext[1],
mom_wv_diff_ten_ext[1],
mom_u_source_ext=0.0,
mom_v_source_ext=0.0,
mom_w_source_ext=0.0,
mom_u_ham_ext=0.0,
dmom_u_ham_grad_p_ext[nSpace],
dmom_u_ham_grad_u_ext[nSpace],
mom_v_ham_ext=0.0,
dmom_v_ham_grad_p_ext[nSpace],
dmom_v_ham_grad_v_ext[nSpace],
mom_w_ham_ext=0.0,
dmom_w_ham_grad_p_ext[nSpace],
dmom_w_ham_grad_w_ext[nSpace],
dmom_u_adv_p_ext[nSpace],
dmom_v_adv_p_ext[nSpace],
dmom_w_adv_p_ext[nSpace],
dflux_mass_u_ext=0.0,
dflux_mass_v_ext=0.0,
dflux_mass_w_ext=0.0,
dflux_mom_u_adv_p_ext=0.0,
dflux_mom_u_adv_u_ext=0.0,
dflux_mom_u_adv_v_ext=0.0,
dflux_mom_u_adv_w_ext=0.0,
dflux_mom_v_adv_p_ext=0.0,
dflux_mom_v_adv_u_ext=0.0,
dflux_mom_v_adv_v_ext=0.0,
dflux_mom_v_adv_w_ext=0.0,
dflux_mom_w_adv_p_ext=0.0,
dflux_mom_w_adv_u_ext=0.0,
dflux_mom_w_adv_v_ext=0.0,
dflux_mom_w_adv_w_ext=0.0,
bc_p_ext=0.0,
bc_u_ext=0.0,
bc_v_ext=0.0,
bc_w_ext=0.0,
bc_mom_u_acc_ext=0.0,
bc_dmom_u_acc_u_ext=0.0,
bc_mom_v_acc_ext=0.0,
bc_dmom_v_acc_v_ext=0.0,
bc_mom_w_acc_ext=0.0,
bc_dmom_w_acc_w_ext=0.0,
bc_mass_adv_ext[nSpace],
bc_dmass_adv_u_ext[nSpace],
bc_dmass_adv_v_ext[nSpace],
bc_dmass_adv_w_ext[nSpace],
bc_mom_u_adv_ext[nSpace],
bc_dmom_u_adv_u_ext[nSpace],
bc_dmom_u_adv_v_ext[nSpace],
bc_dmom_u_adv_w_ext[nSpace],
bc_mom_v_adv_ext[nSpace],
bc_dmom_v_adv_u_ext[nSpace],
bc_dmom_v_adv_v_ext[nSpace],
bc_dmom_v_adv_w_ext[nSpace],
bc_mom_w_adv_ext[nSpace],
bc_dmom_w_adv_u_ext[nSpace],
bc_dmom_w_adv_v_ext[nSpace],
bc_dmom_w_adv_w_ext[nSpace],
bc_mom_uu_diff_ten_ext[nSpace],
bc_mom_vv_diff_ten_ext[nSpace],
bc_mom_ww_diff_ten_ext[nSpace],
bc_mom_uv_diff_ten_ext[1],
bc_mom_uw_diff_ten_ext[1],
bc_mom_vu_diff_ten_ext[1],
bc_mom_vw_diff_ten_ext[1],
bc_mom_wu_diff_ten_ext[1],
bc_mom_wv_diff_ten_ext[1],
bc_mom_u_source_ext=0.0,
bc_mom_v_source_ext=0.0,
bc_mom_w_source_ext=0.0,
bc_mom_u_ham_ext=0.0,
bc_dmom_u_ham_grad_p_ext[nSpace],
bc_dmom_u_ham_grad_u_ext[nSpace],
bc_mom_v_ham_ext=0.0,
bc_dmom_v_ham_grad_p_ext[nSpace],
bc_dmom_v_ham_grad_v_ext[nSpace],
bc_mom_w_ham_ext=0.0,
bc_dmom_w_ham_grad_p_ext[nSpace],
bc_dmom_w_ham_grad_w_ext[nSpace],
fluxJacobian_p_p[nDOF_trial_element],
fluxJacobian_p_u[nDOF_trial_element],
fluxJacobian_p_v[nDOF_trial_element],
fluxJacobian_p_w[nDOF_trial_element],
fluxJacobian_u_p[nDOF_trial_element],
fluxJacobian_u_u[nDOF_trial_element],
fluxJacobian_u_v[nDOF_trial_element],
fluxJacobian_u_w[nDOF_trial_element],
fluxJacobian_v_p[nDOF_trial_element],
fluxJacobian_v_u[nDOF_trial_element],
fluxJacobian_v_v[nDOF_trial_element],
fluxJacobian_v_w[nDOF_trial_element],
fluxJacobian_w_p[nDOF_trial_element],
fluxJacobian_w_u[nDOF_trial_element],
fluxJacobian_w_v[nDOF_trial_element],
fluxJacobian_w_w[nDOF_trial_element],
jac_ext[nSpace*nSpace],
jacDet_ext,
jacInv_ext[nSpace*nSpace],
boundaryJac[nSpace*(nSpace-1)],
metricTensor[(nSpace-1)*(nSpace-1)],
metricTensorDetSqrt,
p_grad_trial_trace[nDOF_trial_element*nSpace],
vel_grad_trial_trace[nDOF_trial_element*nSpace],
dS,
p_test_dS[nDOF_test_element],
vel_test_dS[nDOF_test_element],
normal[2],
x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
vel_grad_test_dS[nDOF_trial_element*nSpace],
//VRANS
porosity_ext,
//
G[nSpace*nSpace],G_dd_G,tr_G,h_phi,h_penalty,penalty;
ck.calculateMapping_elementBoundary(eN,
ebN_local,
kb,
ebN_local_kb,
mesh_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
mesh_grad_trial_trace_ref.data(),
boundaryJac_ref.data(),
jac_ext,
jacDet_ext,
jacInv_ext,
boundaryJac,
metricTensor,
metricTensorDetSqrt,
normal_ref.data(),
normal,
x_ext,y_ext,z_ext);
ck.calculateMappingVelocity_elementBoundary(eN,
ebN_local,
kb,
ebN_local_kb,
mesh_velocity_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
xt_ext,yt_ext,zt_ext,
normal,
boundaryJac,
metricTensor,
integralScaling);
//dS = ((1.0-MOVING_DOMAIN)*metricTensorDetSqrt + MOVING_DOMAIN*integralScaling)*dS_ref[kb];
dS = metricTensorDetSqrt*dS_ref[kb];
ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
ck.calculateGScale(G,&ebqe_normal_phi_ext[ebNE_kb_nSpace],h_phi);
eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter[eN]);
const double particle_eps = particle_epsFact * (useMetrics * h_phi + (1.0 - useMetrics) * elementDiameter[eN]);
//compute shape and solution information
//shape
/* ck.gradTrialFromRef(&p_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,p_grad_trial_trace); */
ck.gradTrialFromRef(&vel_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,vel_grad_trial_trace);
//solution and gradients
/* ck.valFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],&p_trial_trace_ref[ebN_local_kb*nDOF_test_element],p_ext); */
p_ext = ebqe_p[ebNE_kb];
ck.valFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext);
ck.valFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],v_ext);
/* ck.valFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],&vel_trial_trace_ref[ebN_local_kb*nDOF_test_element],w_ext); */
/* ck.gradFromDOF(p_dof,&p_l2g[eN_nDOF_trial_element],p_grad_trial_trace,grad_p_ext); */
for (int I=0;I<nSpace;I++)
grad_p_ext[I] = ebqe_grad_p[ebNE_kb_nSpace+I];
ck.gradFromDOF(u_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_u_ext);
ck.gradFromDOF(v_dof.data(),&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_v_ext);
/* ck.gradFromDOF(w_dof,&vel_l2g[eN_nDOF_trial_element],vel_grad_trial_trace,grad_w_ext); */
//precalculate test function products with integration weights
for (int j=0;j<nDOF_trial_element;j++)
{
/* p_test_dS[j] = p_test_trace_ref[ebN_local_kb*nDOF_test_element+j]*dS; */
vel_test_dS[j] = vel_test_trace_ref[ebN_local_kb*nDOF_test_element+j]*dS;
for (int I=0;I<nSpace;I++)
vel_grad_test_dS[j*nSpace+I] = vel_grad_trial_trace[j*nSpace+I]*dS;//cek hack, using trial
}
//
//load the boundary values
//
bc_p_ext = isDOFBoundary_p[ebNE_kb]*ebqe_bc_p_ext[ebNE_kb]+(1-isDOFBoundary_p[ebNE_kb])*p_ext;
//bc values at moving boundaries are specified relative to boundary motion so we need to add it here
bc_u_ext = isDOFBoundary_u[ebNE_kb]*(ebqe_bc_u_ext[ebNE_kb] + MOVING_DOMAIN*xt_ext) + (1-isDOFBoundary_u[ebNE_kb])*u_ext;
bc_v_ext = isDOFBoundary_v[ebNE_kb]*(ebqe_bc_v_ext[ebNE_kb] + MOVING_DOMAIN*yt_ext) + (1-isDOFBoundary_v[ebNE_kb])*v_ext;
/* bc_w_ext = isDOFBoundary_w[ebNE_kb]*(ebqe_bc_w_ext[ebNE_kb] + MOVING_DOMAIN*zt_ext) + (1-isDOFBoundary_w[ebNE_kb])*w_ext; */
//VRANS
porosity_ext = 1.0 - ebqe_vos_ext[ebNE_kb];
//
//calculate the internal and external trace of the pde coefficients
//
double distance_to_omega_solid = 1e10;
if (use_ball_as_particle == 1)
{
get_distance_to_ball(nParticles, ball_center.data(), ball_radius.data(), x_ext, y_ext, z_ext, distance_to_omega_solid);
}
else
{
distance_to_omega_solid = ebq_global_phi_solid[ebN*nQuadraturePoints_elementBoundary+kb];
}
double eddy_viscosity_ext(0.),bc_eddy_viscosity_ext(0.),rhoSave, nuSave;//not interested in saving boundary eddy viscosity for now
evaluateCoefficients(eps_rho,
eps_mu,
particle_eps,
sigma,
rho_0,
nu_0,
rho_1,
nu_1,
elementDiameter[eN],
smagorinskyConstant,
turbulenceClosureModel,
g.data(),
useVF,
ebqe_vf_ext[ebNE_kb],
ebqe_phi_ext[ebNE_kb],
&ebqe_normal_phi_ext[ebNE_kb_nSpace],
distance_to_omega_solid,
ebqe_kappa_phi_ext[ebNE_kb],
//VRANS
porosity_ext,
//
p_ext,
grad_p_ext,
grad_u_ext,
grad_v_ext,
grad_w_ext,
u_ext,
v_ext,
w_ext,
ebqe_velocity_star[ebNE_kb_nSpace+0],
ebqe_velocity_star[ebNE_kb_nSpace+1],
ebqe_velocity_star[ebNE_kb_nSpace+1],//hack,not used
eddy_viscosity_ext,
mom_u_acc_ext,
dmom_u_acc_u_ext,
mom_v_acc_ext,
dmom_v_acc_v_ext,
mom_w_acc_ext,
dmom_w_acc_w_ext,
mass_adv_ext,
dmass_adv_u_ext,
dmass_adv_v_ext,
dmass_adv_w_ext,
mom_u_adv_ext,
dmom_u_adv_u_ext,
dmom_u_adv_v_ext,
dmom_u_adv_w_ext,
mom_v_adv_ext,
dmom_v_adv_u_ext,
dmom_v_adv_v_ext,
dmom_v_adv_w_ext,
mom_w_adv_ext,
dmom_w_adv_u_ext,
dmom_w_adv_v_ext,
dmom_w_adv_w_ext,
mom_uu_diff_ten_ext,
mom_vv_diff_ten_ext,
mom_ww_diff_ten_ext,
mom_uv_diff_ten_ext,
mom_uw_diff_ten_ext,
mom_vu_diff_ten_ext,
mom_vw_diff_ten_ext,
mom_wu_diff_ten_ext,
mom_wv_diff_ten_ext,
mom_u_source_ext,
mom_v_source_ext,
mom_w_source_ext,
mom_u_ham_ext,
dmom_u_ham_grad_p_ext,
dmom_u_ham_grad_u_ext,
mom_v_ham_ext,
dmom_v_ham_grad_p_ext,
dmom_v_ham_grad_v_ext,
mom_w_ham_ext,
dmom_w_ham_grad_p_ext,
dmom_w_ham_grad_w_ext,
rhoSave,
nuSave,
KILL_PRESSURE_TERM,
0,
0., // mql: zero force term at boundary
0.,
0.,
MATERIAL_PARAMETERS_AS_FUNCTION,
ebqe_density_as_function[ebNE_kb],
ebqe_dynamic_viscosity_as_function[ebNE_kb],
USE_SBM,
x_ext,y_ext,z_ext,
use_ball_as_particle,
ball_center.data(),
ball_radius.data(),
ball_velocity.data(),
ball_angular_velocity.data(),
INT_BY_PARTS_PRESSURE);
evaluateCoefficients(eps_rho,
eps_mu,
particle_eps,
sigma,
rho_0,
nu_0,
rho_1,
nu_1,
elementDiameter[eN],
smagorinskyConstant,
turbulenceClosureModel,
g.data(),
useVF,
bc_ebqe_vf_ext[ebNE_kb],
bc_ebqe_phi_ext[ebNE_kb],
&ebqe_normal_phi_ext[ebNE_kb_nSpace],
distance_to_omega_solid,
ebqe_kappa_phi_ext[ebNE_kb],
//VRANS
porosity_ext,
//
bc_p_ext,
grad_p_ext,
grad_u_ext,
grad_v_ext,
grad_w_ext,
bc_u_ext,
bc_v_ext,
bc_w_ext,
ebqe_velocity_star[ebNE_kb_nSpace+0],
ebqe_velocity_star[ebNE_kb_nSpace+1],
ebqe_velocity_star[ebNE_kb_nSpace+1],//hack,not used
bc_eddy_viscosity_ext,
bc_mom_u_acc_ext,
bc_dmom_u_acc_u_ext,
bc_mom_v_acc_ext,
bc_dmom_v_acc_v_ext,
bc_mom_w_acc_ext,
bc_dmom_w_acc_w_ext,
bc_mass_adv_ext,
bc_dmass_adv_u_ext,
bc_dmass_adv_v_ext,
bc_dmass_adv_w_ext,
bc_mom_u_adv_ext,
bc_dmom_u_adv_u_ext,
bc_dmom_u_adv_v_ext,
bc_dmom_u_adv_w_ext,
bc_mom_v_adv_ext,
bc_dmom_v_adv_u_ext,
bc_dmom_v_adv_v_ext,
bc_dmom_v_adv_w_ext,
bc_mom_w_adv_ext,
bc_dmom_w_adv_u_ext,
bc_dmom_w_adv_v_ext,
bc_dmom_w_adv_w_ext,
bc_mom_uu_diff_ten_ext,
bc_mom_vv_diff_ten_ext,
bc_mom_ww_diff_ten_ext,
bc_mom_uv_diff_ten_ext,
bc_mom_uw_diff_ten_ext,
bc_mom_vu_diff_ten_ext,
bc_mom_vw_diff_ten_ext,
bc_mom_wu_diff_ten_ext,
bc_mom_wv_diff_ten_ext,
bc_mom_u_source_ext,
bc_mom_v_source_ext,
bc_mom_w_source_ext,
bc_mom_u_ham_ext,
bc_dmom_u_ham_grad_p_ext,
bc_dmom_u_ham_grad_u_ext,
bc_mom_v_ham_ext,
bc_dmom_v_ham_grad_p_ext,
bc_dmom_v_ham_grad_v_ext,
bc_mom_w_ham_ext,
bc_dmom_w_ham_grad_p_ext,
bc_dmom_w_ham_grad_w_ext,
rhoSave,
nuSave,
KILL_PRESSURE_TERM,
0,
0., // mql: zero force term at boundary
0.,
0.,
MATERIAL_PARAMETERS_AS_FUNCTION,
ebqe_density_as_function[ebNE_kb],
ebqe_dynamic_viscosity_as_function[ebNE_kb],
USE_SBM,
x_ext,y_ext,z_ext,
use_ball_as_particle,
ball_center.data(),
ball_radius.data(),
ball_velocity.data(),
ball_angular_velocity.data(),
INT_BY_PARTS_PRESSURE);
//Turbulence closure model
if (turbulenceClosureModel >= 3)
{
const double turb_var_grad_0_dummy[2] = {0.,0.};
const double c_mu = 0.09;//mwf hack
updateTurbulenceClosure(turbulenceClosureModel,
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
useVF,
ebqe_vf_ext[ebNE_kb],
ebqe_phi_ext[ebNE_kb],
porosity_ext,
c_mu, //mwf hack
ebqe_turb_var_0[ebNE_kb],
ebqe_turb_var_1[ebNE_kb],
turb_var_grad_0_dummy, //not needed
eddy_viscosity_ext,
mom_uu_diff_ten_ext,
mom_vv_diff_ten_ext,
mom_ww_diff_ten_ext,
mom_uv_diff_ten_ext,
mom_uw_diff_ten_ext,
mom_vu_diff_ten_ext,
mom_vw_diff_ten_ext,
mom_wu_diff_ten_ext,
mom_wv_diff_ten_ext,
mom_u_source_ext,
mom_v_source_ext,
mom_w_source_ext);
updateTurbulenceClosure(turbulenceClosureModel,
eps_rho,
eps_mu,
rho_0,
nu_0,
rho_1,
nu_1,
useVF,
ebqe_vf_ext[ebNE_kb],
ebqe_phi_ext[ebNE_kb],
porosity_ext,
c_mu, //mwf hack
ebqe_turb_var_0[ebNE_kb],
ebqe_turb_var_1[ebNE_kb],
turb_var_grad_0_dummy, //not needed
bc_eddy_viscosity_ext,
bc_mom_uu_diff_ten_ext,
bc_mom_vv_diff_ten_ext,
bc_mom_ww_diff_ten_ext,
bc_mom_uv_diff_ten_ext,
bc_mom_uw_diff_ten_ext,
bc_mom_vu_diff_ten_ext,
bc_mom_vw_diff_ten_ext,
bc_mom_wu_diff_ten_ext,
bc_mom_wv_diff_ten_ext,
bc_mom_u_source_ext,
bc_mom_v_source_ext,
bc_mom_w_source_ext);
}
//
//moving domain
//
mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*xt_ext; //times rho*porosity. mql. CHECK.
mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*yt_ext;
/* mom_u_adv_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*zt_ext; */
dmom_u_adv_u_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*xt_ext;
dmom_u_adv_u_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*yt_ext;
/* dmom_u_adv_u_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*zt_ext; */
mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*xt_ext;
mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*yt_ext;
/* mom_v_adv_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*zt_ext; */
dmom_v_adv_v_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*xt_ext;
dmom_v_adv_v_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*yt_ext;
/* dmom_v_adv_v_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*zt_ext; */
/* mom_w_adv_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*xt_ext; */
/* mom_w_adv_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*yt_ext; */
/* mom_w_adv_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*zt_ext; */
/* dmom_w_adv_w_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*xt_ext; */
/* dmom_w_adv_w_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*yt_ext; */
/* dmom_w_adv_w_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*zt_ext; */
//moving domain bc's
// mql. CHECK.
bc_mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*xt_ext; //times rho*porosity
bc_mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*yt_ext;
/* bc_mom_u_adv_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*zt_ext; */
bc_mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*xt_ext;
bc_mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*yt_ext;
/* bc_mom_v_adv_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*zt_ext; */
/* bc_mom_w_adv_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*xt_ext; */
/* bc_mom_w_adv_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*yt_ext; */
/* bc_mom_w_adv_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*zt_ext; */
//
//calculate the numerical fluxes
//
exteriorNumericalAdvectiveFluxDerivatives(isDOFBoundary_p[ebNE_kb],
isDOFBoundary_u[ebNE_kb],
isDOFBoundary_v[ebNE_kb],
isDOFBoundary_w[ebNE_kb],
isAdvectiveFluxBoundary_p[ebNE_kb],
isAdvectiveFluxBoundary_u[ebNE_kb],
isAdvectiveFluxBoundary_v[ebNE_kb],
isAdvectiveFluxBoundary_w[ebNE_kb],
dmom_u_ham_grad_p_ext[0],//=1/rho
normal,
porosity_ext*dmom_u_acc_u_ext, //multiply by rho. mql. CHECK.
bc_p_ext,
bc_u_ext,
bc_v_ext,
bc_w_ext,
bc_mass_adv_ext,
bc_mom_u_adv_ext,
bc_mom_v_adv_ext,
bc_mom_w_adv_ext,
ebqe_bc_flux_mass_ext[ebNE_kb]+MOVING_DOMAIN*(xt_ext*normal[0]+yt_ext*normal[1]),//bc is relative mass flux
ebqe_bc_flux_mom_u_adv_ext[ebNE_kb],
ebqe_bc_flux_mom_v_adv_ext[ebNE_kb],
ebqe_bc_flux_mom_w_adv_ext[ebNE_kb],
p_ext,
u_ext,
v_ext,
w_ext,
mass_adv_ext,
mom_u_adv_ext,
mom_v_adv_ext,
mom_w_adv_ext,
dmass_adv_u_ext,
dmass_adv_v_ext,
dmass_adv_w_ext,
dmom_u_adv_p_ext,
dmom_u_adv_u_ext,
dmom_u_adv_v_ext,
dmom_u_adv_w_ext,
dmom_v_adv_p_ext,
dmom_v_adv_u_ext,
dmom_v_adv_v_ext,
dmom_v_adv_w_ext,
dmom_w_adv_p_ext,
dmom_w_adv_u_ext,
dmom_w_adv_v_ext,
dmom_w_adv_w_ext,
dflux_mass_u_ext,
dflux_mass_v_ext,
dflux_mass_w_ext,
dflux_mom_u_adv_p_ext,
dflux_mom_u_adv_u_ext,
dflux_mom_u_adv_v_ext,
dflux_mom_u_adv_w_ext,
dflux_mom_v_adv_p_ext,
dflux_mom_v_adv_u_ext,
dflux_mom_v_adv_v_ext,
dflux_mom_v_adv_w_ext,
dflux_mom_w_adv_p_ext,
dflux_mom_w_adv_u_ext,
dflux_mom_w_adv_v_ext,
dflux_mom_w_adv_w_ext,
&ebqe_velocity_star[ebNE_kb_nSpace]);
//
//calculate the flux jacobian
//
ck.calculateGScale(G,normal,h_penalty);
penalty = useMetrics*C_b/h_penalty + (1.0-useMetrics)*ebqe_penalty_ext[ebNE_kb];
for (int j=0;j<nDOF_trial_element;j++)
{
register int j_nSpace = j*nSpace,ebN_local_kb_j=ebN_local_kb*nDOF_trial_element+j;
/* fluxJacobian_p_p[j]=0.0; */
/* fluxJacobian_p_u[j]=ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mass_u_ext,vel_trial_trace_ref[ebN_local_kb_j]); */
/* fluxJacobian_p_v[j]=ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mass_v_ext,vel_trial_trace_ref[ebN_local_kb_j]); */
/* fluxJacobian_p_w[j]=ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mass_w_ext,vel_trial_trace_ref[ebN_local_kb_j]); */
/* fluxJacobian_u_p[j]=ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_u_adv_p_ext,p_trial_trace_ref[ebN_local_kb_j]); */
fluxJacobian_u_u[j] =
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_u_adv_u_ext,vel_trial_trace_ref[ebN_local_kb_j]) +
ExteriorNumericalDiffusiveFluxJacobian(eps_rho,
ebqe_phi_ext[ebNE_kb],
sdInfo_u_u_rowptr.data(),
sdInfo_u_u_colind.data(),
isDOFBoundary_u[ebNE_kb],
isDiffusiveFluxBoundary_u[ebNE_kb],
normal,
mom_uu_diff_ten_ext,
vel_trial_trace_ref[ebN_local_kb_j],
&vel_grad_trial_trace[j_nSpace],
penalty);//ebqe_penalty_ext[ebNE_kb]);
fluxJacobian_u_v[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_u_adv_v_ext,vel_trial_trace_ref[ebN_local_kb_j]) +
ExteriorNumericalDiffusiveFluxJacobian(eps_rho,
ebqe_phi_ext[ebNE_kb],
sdInfo_u_v_rowptr.data(),
sdInfo_u_v_colind.data(),
isDOFBoundary_v[ebNE_kb],
isDiffusiveFluxBoundary_v[ebNE_kb],
normal,
mom_uv_diff_ten_ext,
vel_trial_trace_ref[ebN_local_kb_j],
&vel_grad_trial_trace[j_nSpace],
penalty);//ebqe_penalty_ext[ebNE_kb]);
/*fluxJacobian_u_w[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_u_adv_w_ext,vel_trial_trace_ref[ebN_local_kb_j])+*/
/* ExteriorNumericalDiffusiveFluxJacobian(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_u_w_rowptr, */
/* sdInfo_u_w_colind, */
/* isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_u[ebNE_kb], */
/* normal, */
/* mom_uw_diff_ten_ext, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* &vel_grad_trial_trace[j_nSpace], */
/* penalty);//ebqe_penalty_ext[ebNE_kb]); */
/* fluxJacobian_v_p[j]=ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_v_adv_p_ext,p_trial_trace_ref[ebN_local_kb_j]); */
fluxJacobian_v_u[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_v_adv_u_ext,vel_trial_trace_ref[ebN_local_kb_j]) +
ExteriorNumericalDiffusiveFluxJacobian(eps_rho,
ebqe_phi_ext[ebNE_kb],
sdInfo_v_u_rowptr.data(),
sdInfo_v_u_colind.data(),
isDOFBoundary_u[ebNE_kb],
isDiffusiveFluxBoundary_u[ebNE_kb],
normal,
mom_vu_diff_ten_ext,
vel_trial_trace_ref[ebN_local_kb_j],
&vel_grad_trial_trace[j_nSpace],
penalty);//ebqe_penalty_ext[ebNE_kb]);
fluxJacobian_v_v[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_v_adv_v_ext,vel_trial_trace_ref[ebN_local_kb_j]) +
ExteriorNumericalDiffusiveFluxJacobian(eps_rho,
ebqe_phi_ext[ebNE_kb],
sdInfo_v_v_rowptr.data(),
sdInfo_v_v_colind.data(),
isDOFBoundary_v[ebNE_kb],
isDiffusiveFluxBoundary_v[ebNE_kb],
normal,
mom_vv_diff_ten_ext,
vel_trial_trace_ref[ebN_local_kb_j],
&vel_grad_trial_trace[j_nSpace],
penalty);//ebqe_penalty_ext[ebNE_kb]);
/* fluxJacobian_v_w[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_v_adv_w_ext,vel_trial_trace_ref[ebN_local_kb_j]) + */
/* ExteriorNumericalDiffusiveFluxJacobian(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_v_w_rowptr, */
/* sdInfo_v_w_colind, */
/* isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_v[ebNE_kb], */
/* normal, */
/* mom_vw_diff_ten_ext, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* &vel_grad_trial_trace[j_nSpace], */
/* penalty);//ebqe_penalty_ext[ebNE_kb]); */
/* fluxJacobian_w_p[j]=ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_w_adv_p_ext,p_trial_trace_ref[ebN_local_kb_j]); */
/* fluxJacobian_w_u[j]=ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_w_adv_u_ext,vel_trial_trace_ref[ebN_local_kb_j]) + */
/* ExteriorNumericalDiffusiveFluxJacobian(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_w_u_rowptr, */
/* sdInfo_w_u_colind, */
/* isDOFBoundary_u[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* normal, */
/* mom_wu_diff_ten_ext, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* &vel_grad_trial_trace[j_nSpace], */
/* penalty);//ebqe_penalty_ext[ebNE_kb]); */
/* fluxJacobian_w_v[j]=ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_w_adv_v_ext,vel_trial_trace_ref[ebN_local_kb_j]) + */
/* ExteriorNumericalDiffusiveFluxJacobian(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_w_v_rowptr, */
/* sdInfo_w_v_colind, */
/* isDOFBoundary_v[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* normal, */
/* mom_wv_diff_ten_ext, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* &vel_grad_trial_trace[j_nSpace], */
/* penalty);//ebqe_penalty_ext[ebNE_kb]); */
/* fluxJacobian_w_w[j]=ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_w_adv_w_ext,vel_trial_trace_ref[ebN_local_kb_j]) + */
/* ExteriorNumericalDiffusiveFluxJacobian(eps_rho, */
/* ebqe_phi_ext[ebNE_kb], */
/* sdInfo_w_w_rowptr, */
/* sdInfo_w_w_colind, */
/* isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* normal, */
/* mom_ww_diff_ten_ext, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* &vel_grad_trial_trace[j_nSpace], */
/* penalty);//ebqe_penalty_ext[ebNE_kb]); */
}//j
//
//update the global Jacobian from the flux Jacobian
//
for (int i=0;i<nDOF_test_element;i++)
{
register int eN_i = eN*nDOF_test_element+i;
for (int j=0;j<nDOF_trial_element;j++)
{
register int ebN_i_j = ebN*4*nDOF_test_X_trial_element + i*nDOF_trial_element + j,ebN_local_kb_j=ebN_local_kb*nDOF_trial_element+j;
/* globalJacobian[csrRowIndeces_p_p[eN_i] + csrColumnOffsets_eb_p_p[ebN_i_j]] += fluxJacobian_p_p[j]*p_test_dS[i]; */
/* globalJacobian[csrRowIndeces_p_u[eN_i] + csrColumnOffsets_eb_p_u[ebN_i_j]] += fluxJacobian_p_u[j]*p_test_dS[i]; */
/* globalJacobian[csrRowIndeces_p_v[eN_i] + csrColumnOffsets_eb_p_v[ebN_i_j]] += fluxJacobian_p_v[j]*p_test_dS[i]; */
/* globalJacobian[csrRowIndeces_p_w[eN_i] + csrColumnOffsets_eb_p_w[ebN_i_j]] += fluxJacobian_p_w[j]*p_test_dS[i]; */
/* globalJacobian[csrRowIndeces_u_p[eN_i] + csrColumnOffsets_eb_u_p[ebN_i_j]] += fluxJacobian_u_p[j]*vel_test_dS[i]; */
globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] += fluxJacobian_u_u[j]*vel_test_dS[i]+
ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_u[ebNE_kb],
isDiffusiveFluxBoundary_u[ebNE_kb],
eb_adjoint_sigma,
vel_trial_trace_ref[ebN_local_kb_j],
normal,
sdInfo_u_u_rowptr.data(),
sdInfo_u_u_colind.data(),
mom_uu_diff_ten_ext,
&vel_grad_test_dS[i*nSpace]);
globalJacobian[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_eb_u_v[ebN_i_j]] += fluxJacobian_u_v[j]*vel_test_dS[i]+
ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_v[ebNE_kb],
isDiffusiveFluxBoundary_u[ebNE_kb],
eb_adjoint_sigma,
vel_trial_trace_ref[ebN_local_kb_j],
normal,
sdInfo_u_v_rowptr.data(),
sdInfo_u_v_colind.data(),
mom_uv_diff_ten_ext,
&vel_grad_test_dS[i*nSpace]);
/* globalJacobian[csrRowIndeces_u_w[eN_i] + csrColumnOffsets_eb_u_w[ebN_i_j]] += fluxJacobian_u_w[j]*vel_test_dS[i]+ */
/* ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_u[ebNE_kb], */
/* eb_adjoint_sigma, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* normal, */
/* sdInfo_u_w_rowptr, */
/* sdInfo_u_w_colind, */
/* mom_uw_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace]); */
/* globalJacobian[csrRowIndeces_v_p[eN_i] + csrColumnOffsets_eb_v_p[ebN_i_j]] += fluxJacobian_v_p[j]*vel_test_dS[i]; */
globalJacobian[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_eb_v_u[ebN_i_j]] += fluxJacobian_v_u[j]*vel_test_dS[i]+
ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_u[ebNE_kb],
isDiffusiveFluxBoundary_v[ebNE_kb],
eb_adjoint_sigma,
vel_trial_trace_ref[ebN_local_kb_j],
normal,
sdInfo_v_u_rowptr.data(),
sdInfo_v_u_colind.data(),
mom_vu_diff_ten_ext,
&vel_grad_test_dS[i*nSpace]);
globalJacobian[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] += fluxJacobian_v_v[j]*vel_test_dS[i]+
ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_v[ebNE_kb],
isDiffusiveFluxBoundary_v[ebNE_kb],
eb_adjoint_sigma,
vel_trial_trace_ref[ebN_local_kb_j],
normal,
sdInfo_v_v_rowptr.data(),
sdInfo_v_v_colind.data(),
mom_vv_diff_ten_ext,
&vel_grad_test_dS[i*nSpace]);
/* globalJacobian[csrRowIndeces_v_w[eN_i] + csrColumnOffsets_eb_v_w[ebN_i_j]] += fluxJacobian_v_w[j]*vel_test_dS[i]+ */
/* ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_v[ebNE_kb], */
/* eb_adjoint_sigma, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* normal, */
/* sdInfo_v_w_rowptr, */
/* sdInfo_v_w_colind, */
/* mom_vw_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace]); */
/* globalJacobian[csrRowIndeces_w_p[eN_i] + csrColumnOffsets_eb_w_p[ebN_i_j]] += fluxJacobian_w_p[j]*vel_test_dS[i]; */
/* globalJacobian[csrRowIndeces_w_u[eN_i] + csrColumnOffsets_eb_w_u[ebN_i_j]] += fluxJacobian_w_u[j]*vel_test_dS[i]+ */
/* ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_u[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* eb_adjoint_sigma, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* normal, */
/* sdInfo_w_u_rowptr, */
/* sdInfo_w_u_colind, */
/* mom_wu_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace]); */
/* globalJacobian[csrRowIndeces_w_v[eN_i] + csrColumnOffsets_eb_w_v[ebN_i_j]] += fluxJacobian_w_v[j]*vel_test_dS[i]+ */
/* ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_v[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* eb_adjoint_sigma, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* normal, */
/* sdInfo_w_v_rowptr, */
/* sdInfo_w_v_colind, */
/* mom_wv_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace]); */
/* globalJacobian[csrRowIndeces_w_w[eN_i] + csrColumnOffsets_eb_w_w[ebN_i_j]] += fluxJacobian_w_w[j]*vel_test_dS[i]+ */
/* ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_w[ebNE_kb], */
/* isDiffusiveFluxBoundary_w[ebNE_kb], */
/* eb_adjoint_sigma, */
/* vel_trial_trace_ref[ebN_local_kb_j], */
/* normal, */
/* sdInfo_w_w_rowptr, */
/* sdInfo_w_w_colind, */
/* mom_ww_diff_ten_ext, */
/* &vel_grad_test_dS[i*nSpace]); */
}//j
}//i
}//kb
}//ebNE
gf.useExact=useExact;
gf_s.useExact=useExact;
}//computeJacobian
void calculateVelocityAverage(arguments_dict& args)
{
int nExteriorElementBoundaries_global = args.m_iscalar["nExteriorElementBoundaries_global"];
xt::pyarray<int>& exteriorElementBoundariesArray = args.m_iarray["exteriorElementBoundariesArray"];
int nInteriorElementBoundaries_global = args.m_iscalar["nInteriorElementBoundaries_global"];
xt::pyarray<int>& interiorElementBoundariesArray = args.m_iarray["interiorElementBoundariesArray"];
xt::pyarray<int>& elementBoundaryElementsArray = args.m_iarray["elementBoundaryElementsArray"];
xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.m_iarray["elementBoundaryLocalElementBoundariesArray"];
xt::pyarray<double>& mesh_dof = args.m_darray["mesh_dof"];
xt::pyarray<double>& mesh_velocity_dof = args.m_darray["mesh_velocity_dof"];
double MOVING_DOMAIN = args.m_dscalar["MOVING_DOMAIN"];
xt::pyarray<int>& mesh_l2g = args.m_iarray["mesh_l2g"];
xt::pyarray<double>& mesh_trial_trace_ref = args.m_darray["mesh_trial_trace_ref"];
xt::pyarray<double>& mesh_grad_trial_trace_ref = args.m_darray["mesh_grad_trial_trace_ref"];
xt::pyarray<double>& normal_ref = args.m_darray["normal_ref"];
xt::pyarray<double>& boundaryJac_ref = args.m_darray["boundaryJac_ref"];
xt::pyarray<int>& vel_l2g = args.m_iarray["vel_l2g"];
xt::pyarray<double>& u_dof = args.m_darray["u_dof"];
xt::pyarray<double>& v_dof = args.m_darray["v_dof"];
xt::pyarray<double>& w_dof = args.m_darray["w_dof"];
xt::pyarray<double>& vos_dof = args.m_darray["vos_dof"];
xt::pyarray<double>& vel_trial_trace_ref = args.m_darray["vel_trial_trace_ref"];
xt::pyarray<double>& ebqe_velocity = args.m_darray["ebqe_velocity"];
xt::pyarray<double>& velocityAverage = args.m_darray["velocityAverage"];
int permutations[nQuadraturePoints_elementBoundary];
double xArray_left[nQuadraturePoints_elementBoundary*2],
xArray_right[nQuadraturePoints_elementBoundary*2];
for (int i=0;i<nQuadraturePoints_elementBoundary;i++)
permutations[i]=i;//just to initialize
for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
{
register int ebN = exteriorElementBoundariesArray[ebNE];
for (int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
{
register int ebN_kb_nSpace = ebN*nQuadraturePoints_elementBoundary*nSpace+kb*nSpace,
ebNE_kb_nSpace = ebNE*nQuadraturePoints_elementBoundary*nSpace+kb*nSpace;
velocityAverage[ebN_kb_nSpace+0]=ebqe_velocity[ebNE_kb_nSpace+0];
velocityAverage[ebN_kb_nSpace+1]=ebqe_velocity[ebNE_kb_nSpace+1];
}//ebNE
}
for (int ebNI = 0; ebNI < nInteriorElementBoundaries_global; ebNI++)
{
register int ebN = interiorElementBoundariesArray[ebNI],
left_eN_global = elementBoundaryElementsArray[ebN*2+0],
left_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+0],
right_eN_global = elementBoundaryElementsArray[ebN*2+1],
right_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+1],
left_eN_nDOF_trial_element = left_eN_global*nDOF_trial_element,
right_eN_nDOF_trial_element = right_eN_global*nDOF_trial_element;
double jac[nSpace*nSpace],
jacDet,
jacInv[nSpace*nSpace],
boundaryJac[nSpace*(nSpace-1)],
metricTensor[(nSpace-1)*(nSpace-1)],
metricTensorDetSqrt,
normal[2],
x,y,z,
xt,yt,zt,integralScaling;
for (int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
{
ck.calculateMapping_elementBoundary(left_eN_global,
left_ebN_element,
kb,
left_ebN_element*nQuadraturePoints_elementBoundary+kb,
mesh_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
mesh_grad_trial_trace_ref.data(),
boundaryJac_ref.data(),
jac,
jacDet,
jacInv,
boundaryJac,
metricTensor,
metricTensorDetSqrt,
normal_ref.data(),
normal,
x,y,z);
xArray_left[kb*2+0] = x;
xArray_left[kb*2+1] = y;
/* xArray_left[kb*3+2] = z; */
ck.calculateMapping_elementBoundary(right_eN_global,
right_ebN_element,
kb,
right_ebN_element*nQuadraturePoints_elementBoundary+kb,
mesh_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
mesh_grad_trial_trace_ref.data(),
boundaryJac_ref.data(),
jac,
jacDet,
jacInv,
boundaryJac,
metricTensor,
metricTensorDetSqrt,
normal_ref.data(),
normal,
x,y,z);
ck.calculateMappingVelocity_elementBoundary(left_eN_global,
left_ebN_element,
kb,
left_ebN_element*nQuadraturePoints_elementBoundary+kb,
mesh_velocity_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
xt,yt,zt,
normal,
boundaryJac,
metricTensor,
integralScaling);
xArray_right[kb*2+0] = x;
xArray_right[kb*2+1] = y;
/* xArray_right[kb*3+2] = z; */
}
for (int kb_left=0;kb_left<nQuadraturePoints_elementBoundary;kb_left++)
{
double errorNormMin = 1.0;
for (int kb_right=0;kb_right<nQuadraturePoints_elementBoundary;kb_right++)
{
double errorNorm=0.0;
for (int I=0;I<nSpace;I++)
{
errorNorm += fabs(xArray_left[kb_left*2+I]
-
xArray_right[kb_right*2+I]);
}
if (errorNorm < errorNormMin)
{
permutations[kb_right] = kb_left;
errorNormMin = errorNorm;
}
}
}
for (int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
{
register int ebN_kb_nSpace = ebN*nQuadraturePoints_elementBoundary*nSpace+kb*nSpace;
register double u_left=0.0,
v_left=0.0,
w_left=0.0,
u_right=0.0,
v_right=0.0,
w_right=0.0,
vos_left=0.0,
vos_right=0.0,
porosity_left=0.0,
porosity_right=0.0;
register int left_kb = kb,
right_kb = permutations[kb],
left_ebN_element_kb_nDOF_test_element=(left_ebN_element*nQuadraturePoints_elementBoundary+left_kb)*nDOF_test_element,
right_ebN_element_kb_nDOF_test_element=(right_ebN_element*nQuadraturePoints_elementBoundary+right_kb)*nDOF_test_element;
//
//calculate the velocity solution at quadrature points on left and right
//
ck.valFromDOF(vos_dof.data(),&vel_l2g[left_eN_nDOF_trial_element],&vel_trial_trace_ref[left_ebN_element_kb_nDOF_test_element],vos_left);
ck.valFromDOF(u_dof.data(),&vel_l2g[left_eN_nDOF_trial_element],&vel_trial_trace_ref[left_ebN_element_kb_nDOF_test_element],u_left);
ck.valFromDOF(v_dof.data(),&vel_l2g[left_eN_nDOF_trial_element],&vel_trial_trace_ref[left_ebN_element_kb_nDOF_test_element],v_left);
/* ck.valFromDOF(w_dof,&vel_l2g[left_eN_nDOF_trial_element],&vel_trial_trace_ref[left_ebN_element_kb_nDOF_test_element],w_left); */
//
ck.valFromDOF(vos_dof.data(),&vel_l2g[right_eN_nDOF_trial_element],&vel_trial_trace_ref[right_ebN_element_kb_nDOF_test_element],vos_right);
ck.valFromDOF(u_dof.data(),&vel_l2g[right_eN_nDOF_trial_element],&vel_trial_trace_ref[right_ebN_element_kb_nDOF_test_element],u_right);
ck.valFromDOF(v_dof.data(),&vel_l2g[right_eN_nDOF_trial_element],&vel_trial_trace_ref[right_ebN_element_kb_nDOF_test_element],v_right);
/* ck.valFromDOF(w_dof,&vel_l2g[right_eN_nDOF_trial_element],&vel_trial_trace_ref[right_ebN_element_kb_nDOF_test_element],w_right); */
//
/* porosity_left = 1.0 - vos_left; */
/* porosity_right = 1.0 - vos_right; */
velocityAverage[ebN_kb_nSpace+0]=0.5*(u_left + u_right);
velocityAverage[ebN_kb_nSpace+1]=0.5*(v_left + v_right);
/* velocityAverage[ebN_kb_nSpace+2]=0.5*(w_left + w_right); */
}//ebNI
}
}
void getBoundaryDOFs(arguments_dict& args)
{
xt::pyarray<double>& mesh_dof = args.m_darray["mesh_dof"];
xt::pyarray<int>& mesh_l2g = args.m_iarray["mesh_l2g"];
xt::pyarray<double>& mesh_trial_trace_ref = args.m_darray["mesh_trial_trace_ref"];
xt::pyarray<double>& mesh_grad_trial_trace_ref = args.m_darray["mesh_grad_trial_trace_ref"];
xt::pyarray<double>& dS_ref = args.m_darray["dS_ref"];
xt::pyarray<double>& vel_test_trace_ref = args.m_darray["vel_test_trace_ref"];
xt::pyarray<double>& normal_ref = args.m_darray["normal_ref"];
xt::pyarray<double>& boundaryJac_ref = args.m_darray["boundaryJac_ref"];
xt::pyarray<int>& vel_l2g = args.m_iarray["vel_l2g"];
int nExteriorElementBoundaries_global = args.m_iscalar["nExteriorElementBoundaries_global"];
xt::pyarray<int>& exteriorElementBoundariesArray = args.m_iarray["exteriorElementBoundariesArray"];
xt::pyarray<int>& elementBoundaryElementsArray = args.m_iarray["elementBoundaryElementsArray"];
xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.m_iarray["elementBoundaryLocalElementBoundariesArray"];
xt::pyarray<double>& isBoundary_1D = args.m_darray["isBoundary_1D"];
//
//loop over exterior element boundaries to calculate surface integrals and load into element and global residuals
//
//ebNE is the Exterior element boundary INdex
//ebN is the element boundary INdex
//eN is the element index
for (int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
{
register int ebN = exteriorElementBoundariesArray[ebNE],
eN = elementBoundaryElementsArray[ebN*2+0],
ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0],
eN_nDOF_trial_element = eN*nDOF_trial_element;
register double
elementIsBoundary[nDOF_test_element];
const double* elementResidual_w(NULL);
for (int i=0;i<nDOF_test_element;i++)
elementIsBoundary[i]=0.0;
for (int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
{
register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
ebNE_kb_nSpace = ebNE_kb*nSpace,
ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
ebN_local_kb_nSpace = ebN_local_kb*nSpace;
register double
jac_ext[nSpace*nSpace],
jacDet_ext,
jacInv_ext[nSpace*nSpace],
boundaryJac[nSpace*(nSpace-1)],
metricTensor[(nSpace-1)*(nSpace-1)],
metricTensorDetSqrt,
dS, vel_test_dS[nDOF_test_element],
normal[2],x_ext,y_ext,z_ext;
//compute information about mapping from reference element to physical element
ck.calculateMapping_elementBoundary(eN,
ebN_local,
kb,
ebN_local_kb,
mesh_dof.data(),
mesh_l2g.data(),
mesh_trial_trace_ref.data(),
mesh_grad_trial_trace_ref.data(),
boundaryJac_ref.data(),
jac_ext,
jacDet_ext,
jacInv_ext,
boundaryJac,
metricTensor,
metricTensorDetSqrt,
normal_ref.data(),
normal,
x_ext,y_ext,z_ext);
dS = metricTensorDetSqrt*dS_ref[kb];
//precalculate test function products with integration weights
for (int j=0;j<nDOF_trial_element;j++)
vel_test_dS[j] = fabs(vel_test_trace_ref[ebN_local_kb*nDOF_test_element+j])*dS;
//
//update residuals
//
for (int i=0;i<nDOF_test_element;i++)
elementIsBoundary[i] += vel_test_dS[i];
}//kb
//
//update the element and global residual storage
//
for (int i=0;i<nDOF_test_element;i++)
{
int eN_i = eN*nDOF_test_element+i;
isBoundary_1D[vel_l2g[eN_i]] += elementIsBoundary[i];
}//i
}//ebNE
}
};//RANS3PF2D
inline cppRANS3PF2D_base* newRANS3PF2D(int nSpaceIn,
int nQuadraturePoints_elementIn,
int nDOF_mesh_trial_elementIn,
int nDOF_trial_elementIn,
int nDOF_test_elementIn,
int nQuadraturePoints_elementBoundaryIn,
int CompKernelFlag,
double aDarcy,
double betaForch,
double grain,
double packFraction,
double packMargin,
double maxFraction,
double frFraction,
double sigmaC,
double C3e,
double C4e,
double eR,
double fContact,
double mContact,
double nContact,
double angFriction, double vos_limiter, double mu_fr_limiter )
{
cppRANS3PF2D_base *rvalue = proteus::chooseAndAllocateDiscretization2D<cppRANS3PF2D_base, cppRANS3PF2D, CompKernel>(nSpaceIn,
nQuadraturePoints_elementIn,
nDOF_mesh_trial_elementIn,
nDOF_trial_elementIn,
nDOF_test_elementIn,
nQuadraturePoints_elementBoundaryIn,
CompKernelFlag);
rvalue->setSedClosure(aDarcy,
betaForch,
grain,
packFraction,
packMargin,
maxFraction,
frFraction,
sigmaC,
C3e,
C4e,
eR,
fContact,
mContact,
nContact,
angFriction, vos_limiter, mu_fr_limiter );
return rvalue;
}
} //proteus
#endif
| 58.215471 | 334 | 0.457176 |
2cd61ee2b2735d2569192d944778c4d1ce6c5be9 | 333 | c | C | 78.c | MdMushfikurTalukdar/c-program | 399397744f84f61b7d8f2d1370e23fba9aac84f6 | [
"MIT"
] | null | null | null | 78.c | MdMushfikurTalukdar/c-program | 399397744f84f61b7d8f2d1370e23fba9aac84f6 | [
"MIT"
] | null | null | null | 78.c | MdMushfikurTalukdar/c-program | 399397744f84f61b7d8f2d1370e23fba9aac84f6 | [
"MIT"
] | null | null | null | #include<stdio.h>
int main()
{
int i,numb;
char str[10000];
printf("Enter string 1 : ");
gets(str);
printf("\nEnter number of characters : ");
scanf("%d",&numb);
printf("\nString 2 is : ");
for(i=0; i<numb; i++)
{
printf("%c",str[i]);
}
return 0;
}
| 13.32 | 47 | 0.45045 |
8285aee522d3f26ee0131db3b37dbddea61e6ea7 | 14,116 | c | C | src/backend/storage/ipc/shmem.c | violet2016/gpdb | 2698c82347738c0b8491efa71d4d767f12f9e2b5 | [
"PostgreSQL",
"Apache-2.0"
] | 1 | 2017-11-28T03:13:05.000Z | 2017-11-28T03:13:05.000Z | src/backend/storage/ipc/shmem.c | violet2016/gpdb | 2698c82347738c0b8491efa71d4d767f12f9e2b5 | [
"PostgreSQL",
"Apache-2.0"
] | null | null | null | src/backend/storage/ipc/shmem.c | violet2016/gpdb | 2698c82347738c0b8491efa71d4d767f12f9e2b5 | [
"PostgreSQL",
"Apache-2.0"
] | null | null | null | /*-------------------------------------------------------------------------
*
* shmem.c
* create shared memory and initialize shared memory data structures.
*
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/backend/storage/ipc/shmem.c
*
*-------------------------------------------------------------------------
*/
/*
* POSTGRES processes share one or more regions of shared memory.
* The shared memory is created by a postmaster and is inherited
* by each backend via fork() (or, in some ports, via other OS-specific
* methods). The routines in this file are used for allocating and
* binding to shared memory data structures.
*
* NOTES:
* (a) There are three kinds of shared memory data structures
* available to POSTGRES: fixed-size structures, queues and hash
* tables. Fixed-size structures contain things like global variables
* for a module and should never be allocated after the shared memory
* initialization phase. Hash tables have a fixed maximum size, but
* their actual size can vary dynamically. When entries are added
* to the table, more space is allocated. Queues link data structures
* that have been allocated either within fixed-size structures or as hash
* buckets. Each shared data structure has a string name to identify
* it (assigned in the module that declares it).
*
* (b) During initialization, each module looks for its
* shared data structures in a hash table called the "Shmem Index".
* If the data structure is not present, the caller can allocate
* a new one and initialize it. If the data structure is present,
* the caller "attaches" to the structure by initializing a pointer
* in the local address space.
* The shmem index has two purposes: first, it gives us
* a simple model of how the world looks when a backend process
* initializes. If something is present in the shmem index,
* it is initialized. If it is not, it is uninitialized. Second,
* the shmem index allows us to allocate shared memory on demand
* instead of trying to preallocate structures and hard-wire the
* sizes and locations in header files. If you are using a lot
* of shared memory in a lot of different places (and changing
* things during development), this is important.
*
* (c) In standard Unix-ish environments, individual backends do not
* need to re-establish their local pointers into shared memory, because
* they inherit correct values of those variables via fork() from the
* postmaster. However, this does not work in the EXEC_BACKEND case.
* In ports using EXEC_BACKEND, new backends have to set up their local
* pointers using the method described in (b) above.
*
* (d) memory allocation model: shared memory can never be
* freed, once allocated. Each hash table has its own free list,
* so hash buckets can be reused when an item is deleted. However,
* if one hash table grows very large and then shrinks, its space
* cannot be redistributed to other tables. We could build a simple
* hash bucket garbage collector if need be. Right now, it seems
* unnecessary.
*/
#include "postgres.h"
#include "access/transam.h"
#include "miscadmin.h"
#include "storage/lwlock.h"
#include "storage/pg_shmem.h"
#include "storage/shmem.h"
#include "storage/spin.h"
#include <unistd.h>
/* shared memory global variables */
static PGShmemHeader *ShmemSegHdr; /* shared mem segment header */
static void *ShmemBase; /* start address of shared memory */
static void *ShmemEnd; /* end+1 address of shared memory */
slock_t *ShmemLock; /* spinlock for shared memory and LWLock
* allocation */
static HTAB *ShmemIndex = NULL; /* primary index hashtable for shmem */
static int ShmemSystemPageSize = 0; /* system's page size */
/*
* InitShmemAccess() --- set up basic pointers to shared memory.
*
* Note: the argument should be declared "PGShmemHeader *seghdr",
* but we use void to avoid having to include ipc.h in shmem.h.
*/
void
InitShmemAccess(void *seghdr)
{
PGShmemHeader *shmhdr = (PGShmemHeader *) seghdr;
ShmemSegHdr = shmhdr;
ShmemBase = (void *) shmhdr;
ShmemEnd = (char *) ShmemBase + shmhdr->totalsize;
}
/*
* InitShmemAllocation() --- set up shared-memory space allocation.
*
* This should be called only in the postmaster or a standalone backend.
*/
void
InitShmemAllocation(void)
{
PGShmemHeader *shmhdr = ShmemSegHdr;
Assert(shmhdr != NULL);
#ifdef WIN32
ShmemSystemPageSize = 4096; /* Need a way to get this on Win32 */
#else
ShmemSystemPageSize = sysconf(_SC_PAGESIZE);
#endif
if ( ShmemSystemPageSize <= 1 ||
(ShmemSystemPageSize & ( ShmemSystemPageSize - 1))) // checks for power of 2
{
ereport(ERROR,
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg("invalid page size %d; must be a power of two and not an error", ShmemSystemPageSize)));
}
/*
* Initialize the spinlock used by ShmemAlloc. We have to do the space
* allocation the hard way, since obviously ShmemAlloc can't be called
* yet.
*/
ShmemLock = (slock_t *) (((char *) shmhdr) + shmhdr->freeoffset);
shmhdr->freeoffset += MAXALIGN(sizeof(slock_t));
Assert(shmhdr->freeoffset <= shmhdr->totalsize);
SpinLockInit(ShmemLock);
/* ShmemIndex can't be set up yet (need LWLocks first) */
shmhdr->index = NULL;
ShmemIndex = (HTAB *) NULL;
/*
* Initialize ShmemVariableCache for transaction manager. (This doesn't
* really belong here, but not worth moving.)
*/
ShmemVariableCache = (VariableCache)
ShmemAlloc(sizeof(*ShmemVariableCache));
memset(ShmemVariableCache, 0, sizeof(*ShmemVariableCache));
}
/*
* ShmemAlloc -- allocate max-aligned chunk from shared memory
*
* Assumes ShmemLock and ShmemSegHdr are initialized.
*
* Returns: real pointer to memory or NULL if we are out
* of space. Has to return a real pointer in order
* to be compatible with malloc().
*/
void *
ShmemAlloc(Size size)
{
Size newStart;
Size newFree;
void *newSpace;
/* use volatile pointer to prevent code rearrangement */
volatile PGShmemHeader *shmemseghdr = ShmemSegHdr;
/*
* ensure all space is adequately aligned.
*/
size = MAXALIGN(size);
Assert(shmemseghdr != NULL);
SpinLockAcquire(ShmemLock);
newStart = shmemseghdr->freeoffset;
/* extra alignment for large requests, since they are probably buffers */
if (size >= BLCKSZ)
{
newStart = TYPEALIGN(ShmemSystemPageSize, newStart);
}
newFree = newStart + size;
if (newFree <= shmemseghdr->totalsize)
{
newSpace = (void *) ((char *) ShmemBase + newStart);
shmemseghdr->freeoffset = newFree;
}
else
newSpace = NULL;
SpinLockRelease(ShmemLock);
if (!newSpace)
ereport(WARNING,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of shared memory")));
return newSpace;
}
/*
* ShmemAddrIsValid -- test if an address refers to shared memory
*
* Returns TRUE if the pointer points within the shared memory segment.
*/
bool
ShmemAddrIsValid(const void *addr)
{
return (addr >= ShmemBase) && (addr < ShmemEnd);
}
/*
* InitShmemIndex() --- set up or attach to shmem index table.
*/
void
InitShmemIndex(void)
{
HASHCTL info;
int hash_flags;
/*
* Create the shared memory shmem index.
*
* Since ShmemInitHash calls ShmemInitStruct, which expects the ShmemIndex
* hashtable to exist already, we have a bit of a circularity problem in
* initializing the ShmemIndex itself. The special "ShmemIndex" hash
* table name will tell ShmemInitStruct to fake it.
*/
info.keysize = SHMEM_INDEX_KEYSIZE;
info.entrysize = sizeof(ShmemIndexEnt);
hash_flags = HASH_ELEM;
ShmemIndex = ShmemInitHash("ShmemIndex",
SHMEM_INDEX_SIZE, SHMEM_INDEX_SIZE,
&info, hash_flags);
}
/*
* ShmemInitHash -- Create and initialize, or attach to, a
* shared memory hash table.
*
* We assume caller is doing some kind of synchronization
* so that two processes don't try to create/initialize the same
* table at once. (In practice, all creations are done in the postmaster
* process; child processes should always be attaching to existing tables.)
*
* max_size is the estimated maximum number of hashtable entries. This is
* not a hard limit, but the access efficiency will degrade if it is
* exceeded substantially (since it's used to compute directory size and
* the hash table buckets will get overfull).
*
* init_size is the number of hashtable entries to preallocate. For a table
* whose maximum size is certain, this should be equal to max_size; that
* ensures that no run-time out-of-shared-memory failures can occur.
*
* Note: before Postgres 9.0, this function returned NULL for some failure
* cases. Now, it always throws error instead, so callers need not check
* for NULL.
*/
HTAB *
ShmemInitHash(const char *name, /* table string name for shmem index */
long init_size, /* initial table size */
long max_size, /* max size of the table */
HASHCTL *infoP, /* info about key and bucket size */
int hash_flags) /* info about infoP */
{
bool found;
void *location;
/*
* Hash tables allocated in shared memory have a fixed directory; it can't
* grow or other backends wouldn't be able to find it. So, make sure we
* make it big enough to start with.
*
* The shared memory allocator must be specified too.
*/
infoP->dsize = infoP->max_dsize = hash_select_dirsize(max_size);
infoP->alloc = ShmemAlloc;
hash_flags |= HASH_SHARED_MEM | HASH_ALLOC | HASH_DIRSIZE;
/* look it up in the shmem index */
location = ShmemInitStruct(name,
hash_get_shared_size(infoP, hash_flags),
&found);
/*
* if it already exists, attach to it rather than allocate and initialize
* new space
*/
if (found)
hash_flags |= HASH_ATTACH;
/* Pass location of hashtable header to hash_create */
infoP->hctl = (HASHHDR *) location;
return hash_create(name, init_size, infoP, hash_flags);
}
/*
* ShmemInitStruct -- Create/attach to a structure in shared memory.
*
* This is called during initialization to find or allocate
* a data structure in shared memory. If no other process
* has created the structure, this routine allocates space
* for it. If it exists already, a pointer to the existing
* structure is returned.
*
* Returns: pointer to the object. *foundPtr is set TRUE if the object was
* already in the shmem index (hence, already initialized).
*
* Note: before Postgres 9.0, this function returned NULL for some failure
* cases. Now, it always throws error instead, so callers need not check
* for NULL.
*/
void *
ShmemInitStruct(const char *name, Size size, bool *foundPtr)
{
ShmemIndexEnt *result;
void *structPtr;
LWLockAcquire(ShmemIndexLock, LW_EXCLUSIVE);
if (!ShmemIndex)
{
PGShmemHeader *shmemseghdr = ShmemSegHdr;
/* Must be trying to create/attach to ShmemIndex itself */
Assert(strcmp(name, "ShmemIndex") == 0);
if (IsUnderPostmaster)
{
/* Must be initializing a (non-standalone) backend */
Assert(shmemseghdr->index != NULL);
structPtr = shmemseghdr->index;
*foundPtr = TRUE;
}
else
{
/*
* If the shmem index doesn't exist, we are bootstrapping: we must
* be trying to init the shmem index itself.
*
* Notice that the ShmemIndexLock is released before the shmem
* index has been initialized. This should be OK because no other
* process can be accessing shared memory yet.
*/
Assert(shmemseghdr->index == NULL);
structPtr = ShmemAlloc(size);
if (structPtr == NULL)
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("not enough shared memory for data structure"
" \"%s\" (%lu bytes requested)",
name, (unsigned long) size)));
shmemseghdr->index = structPtr;
*foundPtr = FALSE;
}
LWLockRelease(ShmemIndexLock);
return structPtr;
}
/* look it up in the shmem index */
result = (ShmemIndexEnt *)
hash_search(ShmemIndex, name, HASH_ENTER_NULL, foundPtr);
if (!result)
{
LWLockRelease(ShmemIndexLock);
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("could not create ShmemIndex entry for data structure \"%s\"",
name)));
}
if (*foundPtr)
{
/*
* Structure is in the shmem index so someone else has allocated it
* already. The size better be the same as the size we are trying to
* initialize to, or there is a name conflict (or worse).
*/
if (result->size != size)
{
LWLockRelease(ShmemIndexLock);
ereport(ERROR,
(errmsg("ShmemIndex entry size is wrong for data structure"
" \"%s\": expected %lu, actual %lu",
name,
(unsigned long) size,
(unsigned long) result->size)));
}
structPtr = result->location;
}
else
{
/* It isn't in the table yet. allocate and initialize it */
structPtr = ShmemAlloc(size);
if (structPtr == NULL)
{
/* out of memory; remove the failed ShmemIndex entry */
hash_search(ShmemIndex, name, HASH_REMOVE, NULL);
LWLockRelease(ShmemIndexLock);
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("not enough shared memory for data structure"
" \"%s\" (%lu bytes requested)",
name, (unsigned long) size)));
}
result->size = size;
result->location = structPtr;
}
LWLockRelease(ShmemIndexLock);
Assert(ShmemAddrIsValid(structPtr));
return structPtr;
}
/*
* Add two Size values, checking for overflow
*/
Size
add_size(Size s1, Size s2)
{
Size result;
result = s1 + s2;
/* We are assuming Size is an unsigned type here... */
if (result < s1 || result < s2)
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("requested shared memory size overflows size_t")));
return result;
}
/*
* Multiply two Size values, checking for overflow
*/
Size
mul_size(Size s1, Size s2)
{
Size result;
if (s1 == 0 || s2 == 0)
return 0;
result = s1 * s2;
/* We are assuming Size is an unsigned type here... */
if (result / s2 != s1)
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("requested shared memory size overflows size_t")));
return result;
}
| 30.356989 | 98 | 0.700694 |
9647c7e7e75a26f0ce05190dc55ca254a63bafc2 | 297 | h | C | EXIT/EXIT_Init.h | GeorgeAyman2021/BingBong_Game | 682457d5a26f7f90e2cc1e4495801738631dce27 | [
"Apache-2.0"
] | null | null | null | EXIT/EXIT_Init.h | GeorgeAyman2021/BingBong_Game | 682457d5a26f7f90e2cc1e4495801738631dce27 | [
"Apache-2.0"
] | null | null | null | EXIT/EXIT_Init.h | GeorgeAyman2021/BingBong_Game | 682457d5a26f7f90e2cc1e4495801738631dce27 | [
"Apache-2.0"
] | null | null | null | #ifndef _EXIT_INIT_H
#define _EXIT_INIT_H
void EXIT0_VidInit(void);
void GIE_Enable(void);
void GIE_Disable(void);
void EXIT0_Enable(void);
void EXIT0_Disable(void);
void EXIT1_Enable(void);
void EXIT1_Disable(void);
void EXIT2_Enable(void);
void EXIT2_Disable(void);
#endif
| 16.5 | 26 | 0.747475 |
324c965cd182014274c94e810b63671003071840 | 19,841 | c | C | Core/Src/stm32f1xx_it.c | baiyanlali/CS301-EmbeddedSystem-Project1-Questioner | 535452dff0f3e41afb5ba3b7f89d0d8dcd5f1b94 | [
"MIT"
] | null | null | null | Core/Src/stm32f1xx_it.c | baiyanlali/CS301-EmbeddedSystem-Project1-Questioner | 535452dff0f3e41afb5ba3b7f89d0d8dcd5f1b94 | [
"MIT"
] | null | null | null | Core/Src/stm32f1xx_it.c | baiyanlali/CS301-EmbeddedSystem-Project1-Questioner | 535452dff0f3e41afb5ba3b7f89d0d8dcd5f1b94 | [
"MIT"
] | null | null | null | /* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_it.c
* @brief Interrupt Service Routines.
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f1xx_it.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdio.h>
// #include <string.h>
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
/* USER CODE END TD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
int esp8266_mode = 1; // esp8266_mode = 1 -> server mode, esp8266_mode = 0 -> client mode
int connect_flag = 0; //connect_flag = 0 -> not connected, 1-> TCP not connected but wifi connected, 2-> connected
int sending_flag = 0; //set the sending flag, 1-> is sending, 0 -> is not sending
int link_number = -1; //表示连接序号, 0号连接可client或server连接,其他id只能用于连接远程server,-1表示没有连接
int timer_count = 0;
int connection_counter = 0;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim3;
extern DMA_HandleTypeDef hdma_usart1_rx;
extern DMA_HandleTypeDef hdma_usart2_rx;
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
/* USER CODE BEGIN EV */
// uint8_t rxBuffer[20];
extern uint8_t uart1_rx_buffer[2048]; // for uart1 receive buffer
extern uint8_t uart2_rx_buffer[2048]; // for uart2 receive buffer
/* USER CODE END EV */
/******************************************************************************/
/* Cortex-M3 Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
while (1)
{
}
/* USER CODE END NonMaskableInt_IRQn 1 */
}
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */
}
}
/**
* @brief This function handles Prefetch fault, memory access fault.
*/
void BusFault_Handler(void)
{
/* USER CODE BEGIN BusFault_IRQn 0 */
/* USER CODE END BusFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
/* USER CODE END W1_BusFault_IRQn 0 */
}
}
/**
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void)
{
/* USER CODE BEGIN UsageFault_IRQn 0 */
/* USER CODE END UsageFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
/* USER CODE END W1_UsageFault_IRQn 0 */
}
}
/**
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void)
{
/* USER CODE BEGIN SVCall_IRQn 0 */
/* USER CODE END SVCall_IRQn 0 */
/* USER CODE BEGIN SVCall_IRQn 1 */
/* USER CODE END SVCall_IRQn 1 */
}
/**
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void)
{
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
/* USER CODE END DebugMonitor_IRQn 0 */
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
/* USER CODE END DebugMonitor_IRQn 1 */
}
/**
* @brief This function handles Pendable request for system service.
*/
void PendSV_Handler(void)
{
/* USER CODE BEGIN PendSV_IRQn 0 */
/* USER CODE END PendSV_IRQn 0 */
/* USER CODE BEGIN PendSV_IRQn 1 */
/* USER CODE END PendSV_IRQn 1 */
}
/**
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
/******************************************************************************/
/* STM32F1xx Peripheral Interrupt Handlers */
/* Add here the Interrupt Handlers for the used peripherals. */
/* For the available peripheral interrupt handler names, */
/* please refer to the startup file (startup_stm32f1xx.s). */
/******************************************************************************/
/**
* @brief This function handles DMA1 channel5 global interrupt.
*/
void DMA1_Channel5_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
/* USER CODE END DMA1_Channel5_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_usart1_rx);
/* USER CODE BEGIN DMA1_Channel5_IRQn 1 */
/* USER CODE END DMA1_Channel5_IRQn 1 */
}
/**
* @brief This function handles DMA1 channel6 global interrupt.
*/
void DMA1_Channel6_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Channel6_IRQn 0 */
/* USER CODE END DMA1_Channel6_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_usart2_rx);
/* USER CODE BEGIN DMA1_Channel6_IRQn 1 */
/* USER CODE END DMA1_Channel6_IRQn 1 */
}
/**
* @brief This function handles EXTI line[9:5] interrupts.
*/
void EXTI9_5_IRQHandler(void)
{
/* USER CODE BEGIN EXTI9_5_IRQn 0 */
/* USER CODE END EXTI9_5_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5);
/* USER CODE BEGIN EXTI9_5_IRQn 1 */
/* USER CODE END EXTI9_5_IRQn 1 */
}
/**
* @brief This function handles TIM2 global interrupt.
*/
void TIM2_IRQHandler(void)
{
/* USER CODE BEGIN TIM2_IRQn 0 */
/* USER CODE END TIM2_IRQn 0 */
HAL_TIM_IRQHandler(&htim2);
/* USER CODE BEGIN TIM2_IRQn 1 */
/* USER CODE END TIM2_IRQn 1 */
}
/**
* @brief This function handles TIM3 global interrupt.
*/
void TIM3_IRQHandler(void)
{
/* USER CODE BEGIN TIM3_IRQn 0 */
/* USER CODE END TIM3_IRQn 0 */
HAL_TIM_IRQHandler(&htim3);
/* USER CODE BEGIN TIM3_IRQn 1 */
/* USER CODE END TIM3_IRQn 1 */
}
/**
* @brief This function handles USART1 global interrupt.
*/
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
/* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART1_IRQn 1 */
HAL_UART_RxCpltCallback(&huart1);
HAL_UART_Receive_DMA(&huart1, (uint8_t*) uart1_rx_buffer, 2048);
// HAL_UART_Receive_IT(&huart1,(uint8_t*)rxBuffer,1);
/* USER CODE END USART1_IRQn 1 */
}
/**
* @brief This function handles USART2 global interrupt.
*/
void USART2_IRQHandler(void)
{
/* USER CODE BEGIN USART2_IRQn 0 */
/* USER CODE END USART2_IRQn 0 */
HAL_UART_IRQHandler(&huart2);
/* USER CODE BEGIN USART2_IRQn 1 */
HAL_UART_RxCpltCallback(&huart2);
HAL_UART_Receive_DMA(&huart2, (uint8_t*) uart2_rx_buffer, 2048);
/* USER CODE END USART2_IRQn 1 */
}
/**
* @brief This function handles EXTI line[15:10] interrupts.
*/
void EXTI15_10_IRQHandler(void)
{
/* USER CODE BEGIN EXTI15_10_IRQn 0 */
/* USER CODE END EXTI15_10_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_15);
/* USER CODE BEGIN EXTI15_10_IRQn 1 */
/* USER CODE END EXTI15_10_IRQn 1 */
}
/* USER CODE BEGIN 1 */
void transmit1(uint8_t* msg){
HAL_UART_Transmit(&huart1, (uint8_t *)msg, strlen(msg), 0xffff);
}
void send_msg_uart1(uint8_t *msg, int delay_time)
{
HAL_UART_Transmit(&huart1, (uint8_t *)msg, strlen(msg), 0xffff);
HAL_Delay(delay_time);
}
void send_cmd(uint8_t *cmd, int delay_time)
{
char command[100];
sprintf(command,"Start send command:%s\n",cmd);
// send_msg_uart1(command,20);
HAL_UART_Transmit(&huart2, (uint8_t *)cmd, strlen(cmd), 0xffff);
// send_msg_uart1("Start send command END\n",20);
// HAL_UART_Transmit(&huart1, (uint8_t *)cmd, strlen(cmd), 0xffff);
HAL_Delay(delay_time);
}
void send_cmd_without_delay(uint8_t *cmd)
{
char command[100];
sprintf(command,"Start send command:\n%s\n",cmd);
transmit1(command);
HAL_UART_Transmit(&huart2, (uint8_t *)cmd, strlen(cmd), 0xffff);
transmit1("Start send command END\n");
// HAL_UART_Transmit(&huart1, (uint8_t *)cmd, strlen(cmd), 0xffff);
}
void send_message_without_delay(uint8_t* msg){
uint8_t activate[100];
sprintf(activate, "AT+CIPSEND=%d,%d\r\n", link_number, strlen(msg));
// send_cmd((uint8_t *)activate, 0);
send_cmd_without_delay((uint8_t *)activate);
// transmit1("\n>>>>>SENDING<<<<<\n");
// transmit1(msg);
// transmit1("\n>>>>>SENDING END<<<<<\n");
// send_cmd(msg, 0);
send_cmd_without_delay(msg);
}
void send_message(uint8_t *msg)
{
HAL_Delay(400);
uint8_t activate[100];
sprintf(activate, "AT+CIPSEND=%d,%d\r\n", link_number, strlen(msg));
send_cmd((uint8_t *)activate, 2000);
send_msg_uart1(msg, 500);
// printOut(msg, strlen(msg), 1, connect_flag);
send_cmd(msg, 1000);
}
void connect_to_wifi() {
init_var();
send_msg_uart1((uint8_t*) "start connect to wifi\r\n", 2000);
send_cmd("AT+RST\r\n", 5000);
send_cmd("AT+CWMODE=1\r\n", 2000);
send_cmd("AT+RST\r\n", 5000);
send_cmd("AT+CWJAP=\"SUSTC-WIFI-FAKE\",\"987654321\"\r\n", 10000);
send_cmd("AT+CIPMUX=1\r\n", 5000);
send_cmd("AT+CIPSERVER=1\r\n", 5000);
}
void init_var()
{
connect_flag = 0;
sending_flag = 0;
link_number = -1;
connection_counter = 0;
timer_count = 0;
// StateChange(connect_flag);
HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET);
}
void init_server()
{
init_var();
send_msg_uart1((uint8_t *)"start initialize server\r\n", 0);
send_cmd("AT+CWMODE=3\r\n", 2000);
send_cmd("AT+RST\r\n", 5000);
send_cmd("AT+CWSAP=\"SUSTC-WIFI-FAKE\",\"987654321\",1,0,4,0\r\n", 2000);
// send_cmd("AT+CWSAP=\"SUSTC-WIFI-FAKE\",\"987654321\",5,3,4,0\r\n", 2000);
send_cmd("AT+CIPMUX=1\r\n", 2000);
send_cmd("AT+CIPSERVER=1,8089\r\n", 2000);
send_msg_uart1((uint8_t *)"end initialize server\r\n", 0);
}
// void send_message(uint8_t *msg) {
// HAL_Delay(400);
// uint8_t activate[100];
// sprintf(activate, "AT+CIPSEND=%d,%d\r\n", link_number, strlen(msg));
// send_cmd((uint8_t*) activate, 2000);
// send_msg_uart1(msg, 500);
// printOut(msg, strlen(msg), 1, connect_flag);
// send_cmd(msg, 1000);
// }
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
// send_msg_uart1("MSG RECIEVED\n", 1);
if (huart->Instance == USART1)
{
if (RESET != __HAL_UART_GET_FLAG(&huart1, UART_FLAG_IDLE)) {
__HAL_UART_CLEAR_IDLEFLAG(&huart1);
HAL_UART_DMAStop(&huart1);
uint8_t data_length = 2048 - __HAL_DMA_GET_COUNTER(&hdma_usart1_rx);
send_msg_uart1((uint8_t*) "enter usart receive function\n", 0);
if (link_number != -1 && uart1_rx_buffer[0] == '>'
&& connect_flag == 2) {
sending_flag = 1;
HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, GPIO_PIN_RESET); //1
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); //1
send_message(uart1_rx_buffer + 1);
sending_flag = 0;
HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, GPIO_PIN_SET); //0
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); //1
} else if (strcmp(uart1_rx_buffer, "server\r\n") == 0) {
esp8266_mode = 1;
send_msg_uart1((uint8_t*) "SET AS SERVER\r\n", 0);
send_cmd("AT+CWMODE=3\r\n", 1000);
} else if (strcmp(uart1_rx_buffer, "client\r\n") == 0) {
esp8266_mode = 0;
send_msg_uart1((uint8_t*) "SET AS CLIENT\r\n", 0);
send_cmd("AT+CWJAP?\r\n", 1000);
send_cmd("AT+CIFSR\r\n", 1000);
} else if (strcmp(uart1_rx_buffer, "start\r\n") == 0
&& esp8266_mode == 1) {
// reset();
init_server();
} else if (strcmp(uart1_rx_buffer, "connect to wifi\r\n") == 0
&& esp8266_mode == 0) {
// reset();
connect_to_wifi();
} else if (strcmp(uart1_rx_buffer, "connect to server\r\n") == 0
&& esp8266_mode == 0) {
send_cmd((uint8_t*) "AT+CIPSTART=0,\"TCP\",\"192.168.4.1\",8089\r\n", 0);
} else if (strcmp(uart1_rx_buffer, "close connection\r\n") == 0) {
send_cmd((uint8_t*) "AT+CIPCLOSE=0\r\n", 2000);
init_var();
} else if (strncmp(uart1_rx_buffer, "quit wifi\r\n") == 0
&& esp8266_mode == 0) {
send_cmd("AT+CWQAP\r\n", 1000);
init_var();
} else if (strncmp(uart1_rx_buffer, "ip status\r\n") == 0) {
send_cmd("AT+CIPSTATUS\r\n", 1000);
send_cmd("AT+CIFSR\r\n", 1000);
} else if (strncmp(uart1_rx_buffer, "wifi status\r\n") == 0) {
// send_cmd("AT+CWSAP?\r\n", 1000);
send_cmd("AT+CWLIF\r\n", 1000);
send_cmd("AT+CIPSTATUS\r\n", 1000);
} else {
HAL_UART_Transmit(&huart2, (uint8_t*) uart1_rx_buffer,
data_length, 0xffff);
HAL_UART_Transmit(&huart1, (uint8_t*) uart1_rx_buffer,
data_length, 0xffff);
}
memset(uart1_rx_buffer, 0, data_length);
data_length = 0;
HAL_UART_Receive_DMA(&huart1, (uint8_t*) uart1_rx_buffer, 2048);
}
// // send_msg_uart1("USART1 RECIEVED\n", 1);
// // uint8_t data_length = 2048 - __HAL_DMA_GET_COUNTER(&hdma_usart1_rx);
// static unsigned char uRx_Data[20] = {0};
// static unsigned char uLength = 0;
// if (rxBuffer[0] == '\n')
// {
// uLength = 0;
// HAL_UART_Transmit(&huart1, (uint8_t *)uRx_Data, 12, HAL_MAX_DELAY);
// Answer(uRx_Data);
// for (int i = 0; i < 20; i++)
// {
// uRx_Data[i] = '\0';
// }
// for (int i = 0; i < 20; i++)
// {
// rxBuffer[i] = '\0';
// }
// }
// else if (rxBuffer[0] == '\r')
// {
// //HAL_UART_Transmit(&huart1,(uint8_t*)"BEST WISHES\n",12,HAL_MAX_DELAY);
// }
// else
// {
// uRx_Data[uLength] = rxBuffer[0];
// uLength++;
// }
}
else if (huart->Instance == USART2)
{
if (RESET != __HAL_UART_GET_FLAG(&huart2, UART_FLAG_IDLE)) {
__HAL_UART_CLEAR_IDLEFLAG(&huart2);
HAL_UART_DMAStop(&huart2);
uint8_t data_length = 2048 - __HAL_DMA_GET_COUNTER(&hdma_usart2_rx);
if (strncmp(uart2_rx_buffer, "WIFI CONNECTED\r\n", 16) == 0
&& connect_flag == 0) {
connect_flag = 1;
HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, GPIO_PIN_SET); //0
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); //1
link_number = 0;
} else if (strncmp(uart2_rx_buffer, "WIFI GOT IP\r\n", 13) == 0) { // client 端会收到这个消息, 这里变成连接状态
connect_flag = 1;
HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, GPIO_PIN_SET); //0
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); //1
link_number = 0;
} else if (connect_flag == 1
&& strncmp(uart2_rx_buffer, (uint8_t*) "+", 1) == 0) {
if (strstr(uart2_rx_buffer, "+timeout") != NULL) {
if (connection_counter > 2) {
send_msg_uart1((uint8_t*) "connection closed\r\n", 100);
send_cmd((uint8_t*) "AT+CWQAP\r\n", 2000);
init_var();
connection_counter = 0;
// StateChange(0);
} else {
send_msg_uart1((uint8_t*) "connection disturbance\r\n",
100);
++connection_counter;
}
} else {
connection_counter = 0;
// send_msg_uart1((uint8_t *) "connection alive\r\n", 100);
}
} else if (connect_flag == 2) {
if (strcmp(uart2_rx_buffer, "WIFI DISCONNECT\r\n", 16) == 0) { //client 端会收到这个消息
init_var();
HAL_UART_Transmit(&huart1, (uint8_t*) uart2_rx_buffer,
data_length, 0xffff);
} else if (strncmp(uart2_rx_buffer, "\r\n+IPD,", 7) == 0) {
HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, GPIO_PIN_RESET); //1
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); //1
// HAL_UART_Transmit(&huart1, (uint8_t*) uart2_rx_buffer,
// data_length, 0xffff);
// send_msg_uart1("Start Recieve\n",10);
// send_msg_uart1(uart2_rx_buffer,10);
// send_msg_uart1("End Recieve\n",10);
HAL_UART_Transmit(&huart1, (uint8_t *)"Start Recieve\n", strlen("Start Recieve\n"), 0xffff);
HAL_UART_Transmit(&huart1, (uint8_t *)uart2_rx_buffer, strlen(uart2_rx_buffer), 0xffff);
HAL_UART_Transmit(&huart1, (uint8_t *)"END Recieve\n", strlen("END Recieve\n"), 0xffff);
//TODO: 在这里接收
// char * idx = strchr((char*) uart2_rx_buffer, ':') + 1;
// send_msg_uart1(idx,0);
Answer(uart2_rx_buffer);
// printOut(uart2_rx_buffer + 1 + idx, data_length - idx, 2,
// connect_flag);
} else if (strncmp(uart2_rx_buffer, (uint8_t*) "SEND FAIL", 9)
== 0) {
init_var();
HAL_UART_Transmit(&huart1, (uint8_t*) uart2_rx_buffer,
data_length, 0xffff);
} else if (strncmp(uart2_rx_buffer, (uint8_t*) "0,CLOSE OK", 10)
== 0) {
connect_flag = 1;
sending_flag = 0;
link_number = -1;
connection_counter = 0;
timer_count = 0;
HAL_UART_Transmit(&huart1, (uint8_t*) uart2_rx_buffer,
data_length, 0xffff);
}
} else if (strncmp(uart2_rx_buffer, "0,CONNECT\r\n", 11) == 0) {
//server 端要设置
link_number = 0;
connect_flag = 2;
// StateChange(connect_flag);
HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, GPIO_PIN_SET); //0
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); //1
HAL_UART_Transmit(&huart1, (uint8_t*) "Connection on id 0\r\n",
20, 0xffff);
Question();
} else if (strncmp(uart2_rx_buffer, "0,CONNECT FAIL\r\n", 16) == 0 ||
strstr(uart2_rx_buffer, "0,CLOSED\r\n") != NULL) {
init_var();
HAL_UART_Transmit(&huart1,
(uint8_t*) "Close connection on id 0\r\n", 26, 0xffff);
} else if (strncmp(uart2_rx_buffer, "0,CLOSED\r\n", 10) == 0) {
connect_flag = 1;
sending_flag = 0;
link_number = -1;
connection_counter = 0;
timer_count = 0;
HAL_UART_Transmit(&huart1,
(uint8_t*) "connection closed on id 0\r\n", 26, 0xffff);
} else {
uint8_t msg[15];
sprintf(msg, "data length=%d\r\n", data_length);
HAL_UART_Transmit(&huart1, (uint8_t *) msg, strlen(msg), 0xffff);
// send to uart1 again, to show on the usart1 display
HAL_UART_Transmit(&huart1, (uint8_t*) uart2_rx_buffer,
data_length, 0xffff);
}
memset(uart2_rx_buffer, 0, data_length);
data_length = 0;
HAL_UART_Receive_DMA(&huart2, (uint8_t*) uart2_rx_buffer, 2048);
}
}else{
send_msg_uart1("USART UNKNOWN RECIEVED\n", 1);
}
}
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
| 30.76124 | 114 | 0.615695 |
65da67fb1f0818362f284f88e801671bb9103580 | 4,360 | c | C | src/main.c | eratsu/zezeniadumper | c536d93f94a796ebb701bb059ff2aeebfd1de87f | [
"MIT"
] | 2 | 2020-10-06T11:54:15.000Z | 2020-10-12T12:35:29.000Z | src/main.c | eratsu/zezeniadumper | c536d93f94a796ebb701bb059ff2aeebfd1de87f | [
"MIT"
] | null | null | null | src/main.c | eratsu/zezeniadumper | c536d93f94a796ebb701bb059ff2aeebfd1de87f | [
"MIT"
] | 2 | 2020-10-02T15:40:43.000Z | 2020-10-02T17:28:49.000Z | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "d_bitmap_v4.h"
int main()
{
FILE *fp = NULL, // file pointer for the zezena.gfx
*fb = NULL; // file pointer for each bmp created
char name[100]; // buffer to store the filename of each bmp
long offset = 0; // offset in decimal for debugging purposes
uint32_t sprites; // number of sprites in the file
uint16_t width; // width of sprite
uint16_t height; // height of sprite
uint32_t dataLength; // length of data for a specific sprite
D_PIXEL_A p; // struct that holds the pixel colored data
uint8_t v1, v2, v3, v4; // aux variable to hold the pixel data, i create this because you have to check for 0x1 on the first pixel data to add transparent pixel
uint32_t total, // total bytes that a sprite have the formula is width * height * 4. (rgba)
processed; // the sprite data doesn't always have the full data,
// if the left over of the sprite is transparent you have to complete it based on total - processed
// opening the gfx in binary mode
fp = fopen("zezenia.gfx", "rb");
// checking for errors opening the file
if (fp == NULL)
{
printf("Place the zezenia.gfx in the same folder as the executable!");
return 1;
}
// skipping first 5 bytes, could be a signature or other thing
fseek(fp, 5, SEEK_SET);
offset += 5;
// reading the number of sprites
fread(&sprites, sizeof(uint32_t), 1, fp);
offset += sizeof(uint32_t);
printf("sprite count %u.\n", sprites);
printf("offset %u.\n", offset);
// iterate over all sprites
for (uint32_t j = 0; j < sprites; j++)
{
printf("processing sprite %u from offset %u.\n", j + 1, offset);
// reading the information of sprite j
fread(&width, sizeof(uint16_t), 1, fp);
fread(&height, sizeof(uint16_t), 1, fp);
fread(&dataLength, sizeof(uint32_t), 1, fp);
offset += sizeof(uint8_t) * 8;
printf("width: %u height %u size %u\n\n", width, height, dataLength);
// creating the filename for sprite j
sprintf(name, "./output/%u.bmp", j + 1);
// opening a file for write the sprite data
fb = fopen(name, "wb");
// calculating the size of the bmp
uint32_t rawSize = width * height * PIXEL_V4_SIZE;
// creating the header for the bmp
d_write_bmp_header_v4(fb, HEADER_V4_SIZE + rawSize);
d_write_dib_header_v4(fb, width, height, rawSize);
total = width * height * 4;
processed = 0;
while (dataLength > 0)
{
// reading the first two bytes to check transparency insertion
fread(&v1, sizeof(uint8_t), 1, fp);
fread(&v2, sizeof(uint8_t), 1, fp);
// if the first pixel data has a 0x1 value we need to add v2 times of transparent pixels
//&& dataLength < total
if (v1 == 0x1)
{
// transparent pixel
p.r = 0x00;
p.g = 0x00;
p.b = 0x00;
p.a = 0x00;
for (int i = 0; i < v2; i++)
{
// saving in the bmp file
d_write_pixel_v4_n(fb, p);
processed += 4;
}
// update dataLenght left to process and offset
offset += 2 * sizeof(uint8_t);
dataLength -= 2 * sizeof(uint8_t);
}
// read the other 2 bytes and write the pixel rgba data
else
{
// reading the last 2 bytes of a pixel
fread(&v3, sizeof(uint8_t), 1, fp);
fread(&v4, sizeof(uint8_t), 1, fp);
// case for the background image of the client it has a reserved size of 2048x2048, but the size of the image is less than this resolution
// so you can read until you find 0x0 0x0 0x0 0x0 for optimization
if (v1 == 0x0 && v2 == 0x0 && v3 == 0x0 && v4 == 0x0)
{
offset += 4 * sizeof(uint8_t);
dataLength -= 4 * sizeof(uint8_t);
offset += dataLength;
// skipping all the zeros
fseek(fp, dataLength, SEEK_CUR);
break;
}
// populate the pixel struct
p.r = v1;
p.g = v2;
p.b = v3;
p.a = v4;
// saving in the bmp file
d_write_pixel_v4_n(fb, p);
// update processed/offset/datalength
processed += 4;
offset += 4 * sizeof(uint8_t);
dataLength -= 4 * sizeof(uint8_t);
}
}
// fill the rest of sprite with transparent pixels
if (processed < total)
{
// creating the transparent pixel
p.r = 0x00;
p.g = 0x00;
p.b = 0x00;
p.a = 0x00;
for (uint32_t i = 0; i < total - processed; i++)
{
// write pixel in the bmp
d_write_pixel_v4_n(fb, p);
}
}
fclose(fb);
}
fclose(fp);
return 0;
} | 29.066667 | 161 | 0.639679 |
d65c5a53b7c410c2bbd843aea4e7087c2487597b | 292 | h | C | lib/libc/arch/mips64/gdtoa/gd_qnan.h | ArrogantWombatics/openbsd-src | 75721e1d44322953075b7c4b89337b163a395291 | [
"BSD-3-Clause"
] | 2 | 2020-04-15T13:39:01.000Z | 2020-08-28T01:27:00.000Z | lib/libc/arch/mips64/gdtoa/gd_qnan.h | ArrogantWombatics/openbsd-src | 75721e1d44322953075b7c4b89337b163a395291 | [
"BSD-3-Clause"
] | 1 | 2018-08-21T03:56:33.000Z | 2018-08-21T03:56:33.000Z | lib/libc/arch/mips64/gdtoa/gd_qnan.h | ArrogantWombatics/openbsd-src | 75721e1d44322953075b7c4b89337b163a395291 | [
"BSD-3-Clause"
] | 1 | 2020-08-28T01:25:41.000Z | 2020-08-28T01:25:41.000Z | #define f_QNAN 0x7fbfffff
#define d_QNAN0 0x7ff7ffff
#define d_QNAN1 0xffffffff
#define ld_QNAN0 0x7fff8000
#define ld_QNAN1 0x0
#define ld_QNAN2 0x0
#define ld_QNAN3 0x0
#define ldus_QNAN0 0x7fff
#define ldus_QNAN1 0x8000
#define ldus_QNAN2 0x0
#define ldus_QNAN3 0x0
#define ldus_QNAN4 0x0
| 22.461538 | 27 | 0.835616 |
681aac8eea82a2e679d33574e85368f88502616b | 8,043 | c | C | test/test_logl.c | calebcase/qdm | 2ee95bec6c8be64f69e231c78f2be5fce3509c67 | [
"Apache-2.0"
] | null | null | null | test/test_logl.c | calebcase/qdm | 2ee95bec6c8be64f69e231c78f2be5fce3509c67 | [
"Apache-2.0"
] | 3 | 2020-03-06T18:09:06.000Z | 2020-03-22T20:22:53.000Z | test/test_logl.c | calebcase/qdm | 2ee95bec6c8be64f69e231c78f2be5fce3509c67 | [
"Apache-2.0"
] | null | null | null | #include <munit.h>
#include <qdm.h>
#include "test.h"
static
MunitResult
test_qdm_find_tau(
MUNIT_UNUSED const MunitParameter params[],
MUNIT_UNUSED void* fixture
)
{
int status = 0;
double v = 13.2690000000000001;
size_t spline_df = 3;
double knots_data[] = {
0, 0, 0,
0.15105263157894738,
0.89000000000000001,
1, 1, 1,
};
gsl_vector_view knots = gsl_vector_view_array(knots_data, sizeof(knots_data) / sizeof(double));
munit_log_vector_dim(MUNIT_LOG_DEBUG, &knots.vector);
double mmm_data[] = {
11.238269445477158115,
4.895972702379758346,
7.532858237364849607,
0.044915009573709898,
3.758967035354607855,
1.866387742201979227,
};
gsl_vector_view mmm = gsl_vector_view_array(mmm_data, sizeof(mmm_data) / sizeof(double));
munit_log_vector_dim(MUNIT_LOG_DEBUG, &mmm.vector);
double result = 0;
double expected = 0.023441441362023058;
status = qdm_find_tau(&result, v, spline_df, &knots.vector, &mmm.vector);
munit_assert_int(status, ==, 0);
munit_assert_double_equal(expected, result, 10);
return MUNIT_OK;
}
static
MunitResult
test_qdm_logl_less_than(
MUNIT_UNUSED const MunitParameter params[],
MUNIT_UNUSED void* fixture
)
{
int status = 0;
size_t spline_df = 3;
double knots_data[] = {
0, 0, 0,
0.15105263157894738,
0.89000000000000001,
1, 1, 1,
};
gsl_vector_view knots = gsl_vector_view_array(knots_data, sizeof(knots_data) / sizeof(double));
munit_log_vector_dim(MUNIT_LOG_DEBUG, &knots.vector);
double min = 1e-04;
double theta_data[] = {
11.2382694454771581, 4.89597270237975835, 7.53285823736484961, 0.0449150095737098978, 3.75896703535460786, 1.86638774220197923,
1.5098447359663183, -0.42943079543658147, -0.13782001356078322, -0.0091277541152237976, 0.55811649692923071, 0.28116069158352697,
};
gsl_matrix_view theta = gsl_matrix_view_array(theta_data, 2, 6);
qdm_theta_matrix_constrain(&theta.matrix, min);
double mmm_data[] = {
11.238269445477158115,
4.895972702379758346,
7.532858237364849607,
0.044915009573709898,
3.758967035354607855,
1.866387742201979227,
};
gsl_vector_view mmm = gsl_vector_view_array(mmm_data, 6);
double v = 10.983000000000001;
double tau_low = 0.01;
double tau_high = 0.98999999999999999;
double xi_low = 0.20000000000000001;
double xi_high = 0.20000000000000001;
double log_likelihood = 0;
double tau = 0;
status = qdm_logl(
&log_likelihood,
&tau,
v,
spline_df,
&knots.vector,
&mmm.vector,
tau_low,
tau_high,
xi_low,
xi_high
);
munit_assert_int(status, ==, 0);
double expected_log_likelihood = -5.9039234039068802;
double expected_tau = 0.0030463905316060647;
munit_assert_double_equal(log_likelihood, expected_log_likelihood, 10);
munit_assert_double_equal(tau, expected_tau, 10);
return MUNIT_OK;
}
static
MunitResult
test_qdm_logl_greater_than(
MUNIT_UNUSED const MunitParameter params[],
MUNIT_UNUSED void* fixture
)
{
int status = 0;
size_t spline_df = 3;
double knots_data[] = {
0, 0, 0,
0.15105263157894738,
0.89000000000000001,
1, 1, 1,
};
gsl_vector_view knots = gsl_vector_view_array(knots_data, sizeof(knots_data) / sizeof(double));
munit_log_vector_dim(MUNIT_LOG_DEBUG, &knots.vector);
double min = 1e-04;
double theta_data[] = {
11.2382694454771581, 4.89597270237975835, 7.53285823736484961, 0.0449150095737098978, 3.75896703535460786, 1.86638774220197923,
1.5098447359663183, -0.42943079543658147, -0.13782001356078322, -0.0091277541152237976, 0.55811649692923071, 0.28116069158352697,
};
gsl_matrix_view theta = gsl_matrix_view_array(theta_data, 2, 6);
qdm_theta_matrix_constrain(&theta.matrix, min);
double mmm_data[] = {
11.823719445137566453,
4.729458720475777866,
7.479417823943321331,
0.041375676345357812,
3.975379554572064489,
1.975409234856816187,
};
gsl_vector_view mmm = gsl_vector_view_array(mmm_data, 6);
double v = 30.0829999999999984;
double tau_low = 0.01;
double tau_high = 0.98999999999999999;
double xi_low = 0.20000000000000001;
double xi_high = 0.20000000000000001;
double log_likelihood = 0;
double tau = 0;
status = qdm_logl(
&log_likelihood,
&tau,
v,
spline_df,
&knots.vector,
&mmm.vector,
tau_low,
tau_high,
xi_low,
xi_high
);
munit_assert_int(status, ==, 0);
double expected_log_likelihood = -5.1365196361984982;
double expected_tau = 0.9965798555939035;
munit_assert_double_equal(log_likelihood, expected_log_likelihood, 10);
munit_assert_double_equal(tau, expected_tau, 10);
return MUNIT_OK;
}
static
MunitResult
test_qdm_logl_within(
MUNIT_UNUSED const MunitParameter params[],
MUNIT_UNUSED void* fixture
)
{
int status = 0;
size_t spline_df = 3;
double knots_data[] = {
0, 0, 0,
0.15105263157894738,
0.89000000000000001,
1, 1, 1,
};
gsl_vector_view knots = gsl_vector_view_array(knots_data, sizeof(knots_data) / sizeof(double));
munit_log_vector_dim(MUNIT_LOG_DEBUG, &knots.vector);
double min = 1e-04;
double theta_data[] = {
11.2382694454771581, 4.89597270237975835, 7.53285823736484961, 0.0449150095737098978, 3.75896703535460786, 1.86638774220197923,
1.5098447359663183, -0.42943079543658147, -0.13782001356078322, -0.0091277541152237976, 0.55811649692923071, 0.28116069158352697,
};
gsl_matrix_view theta = gsl_matrix_view_array(theta_data, 2, 6);
qdm_theta_matrix_constrain(&theta.matrix, min);
double mmm_data[] = {
11.238269445477158115,
4.895972702379758346,
7.532858237364849607,
0.044915009573709898,
3.758967035354607855,
1.866387742201979227,
};
gsl_vector_view mmm = gsl_vector_view_array(mmm_data, 6);
double v = 13.2690000000000001;
double tau_low = 0.01;
double tau_high = 0.98999999999999999;
double xi_low = 0.20000000000000001;
double xi_high = 0.20000000000000001;
double log_likelihood = 0;
double tau = 0;
status = qdm_logl(
&log_likelihood,
&tau,
v,
spline_df,
&knots.vector,
&mmm.vector,
tau_low,
tau_high,
xi_low,
xi_high
);
munit_assert_int(status, ==, 0);
double expected_log_likelihood = -4.3381416615763744;
double expected_tau = 0.023441441362023058;
munit_assert_double_equal(log_likelihood, expected_log_likelihood, 10);
munit_assert_double_equal(tau, expected_tau, 10);
return MUNIT_OK;
}
MunitTest tests_logl[] = {
{
"/qdm_find_tau" , // name
test_qdm_find_tau , // test
NULL , // setup
NULL , // tear_down
MUNIT_TEST_OPTION_NONE , // options
NULL , // parameters
},
{
"/qdm_logl/less_than" , // name
test_qdm_logl_less_than , // test
NULL , // setup
NULL , // tear_down
MUNIT_TEST_OPTION_NONE , // options
NULL , // parameters
},
{
"/qdm_logl/greater_than" , // name
test_qdm_logl_greater_than , // test
NULL , // setup
NULL , // tear_down
MUNIT_TEST_OPTION_NONE , // options
NULL , // parameters
},
{
"/qdm_logl/within" , // name
test_qdm_logl_within , // test
NULL , // setup
NULL , // tear_down
MUNIT_TEST_OPTION_NONE , // options
NULL , // parameters
},
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
};
static const MunitSuite test_suite_logl = {
"/logl" , // name
tests_logl , // tests
NULL , // suites
1 , // iterations
MUNIT_SUITE_OPTION_NONE , // options
};
| 24.978261 | 136 | 0.66132 |
d05a9158743d253cf35f615fc2dae3b65149db3e | 556 | h | C | KayzrStaff_Shared/KayzrStaff_Shared.h | Mafken/KayzrStaff-IOS | 00ac0a4889ef381d0b8e247d6ce0e73144da16fe | [
"BSD-2-Clause"
] | null | null | null | KayzrStaff_Shared/KayzrStaff_Shared.h | Mafken/KayzrStaff-IOS | 00ac0a4889ef381d0b8e247d6ce0e73144da16fe | [
"BSD-2-Clause"
] | null | null | null | KayzrStaff_Shared/KayzrStaff_Shared.h | Mafken/KayzrStaff-IOS | 00ac0a4889ef381d0b8e247d6ce0e73144da16fe | [
"BSD-2-Clause"
] | 1 | 2018-01-10T21:10:52.000Z | 2018-01-10T21:10:52.000Z | //
// KayzrStaff_Shared.h
// KayzrStaff_Shared
//
// Created by Jens Leirens on 05/12/2017.
// Copyright © 2017 Jens Leirens. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for KayzrStaff_Shared.
FOUNDATION_EXPORT double KayzrStaff_SharedVersionNumber;
//! Project version string for KayzrStaff_Shared.
FOUNDATION_EXPORT const unsigned char KayzrStaff_SharedVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <KayzrStaff_Shared/PublicHeader.h>
| 27.8 | 142 | 0.784173 |
fdb3762b8376bf1f99efac56a05797e2b89c7647 | 737 | h | C | src/util/util_math.h | oashnic/dxvk | 78ef4cfd92cb7f448292aaca83091914ab271257 | [
"Zlib"
] | 1,015 | 2019-02-07T16:57:51.000Z | 2022-03-23T23:45:02.000Z | src/util/util_math.h | oashnic/dxvk | 78ef4cfd92cb7f448292aaca83091914ab271257 | [
"Zlib"
] | 446 | 2019-03-01T19:13:27.000Z | 2022-03-03T01:52:17.000Z | src/util/util_math.h | oashnic/dxvk | 78ef4cfd92cb7f448292aaca83091914ab271257 | [
"Zlib"
] | 74 | 2019-02-13T02:53:39.000Z | 2021-12-28T05:23:50.000Z | #pragma once
#include <cmath>
namespace dxvk {
constexpr size_t CACHE_LINE_SIZE = 64;
template<typename T>
constexpr T clamp(T n, T lo, T hi) {
if (n < lo) return lo;
if (n > hi) return hi;
return n;
}
template<typename T, typename U = T>
constexpr T align(T what, U to) {
return (what + to - 1) & ~(to - 1);
}
template<typename T, typename U = T>
constexpr T alignDown(T what, U to) {
return (what / to) * to;
}
// Equivalent of std::clamp for use with floating point numbers
// Handles (-){INFINITY,NAN} cases.
// Will return min in cases of NAN, etc.
inline float fclamp(float value, float min, float max) {
return std::fmin(
std::fmax(value, min), max);
}
} | 21.676471 | 65 | 0.609227 |
659dd421023e803efd289dd3e7253cba2e8ade86 | 21,206 | c | C | tools/psp-prxgen.c | erique/pspsdk | e6b7dd27dc044f8b6b05ea0c9494068c29e72e40 | [
"BSD-3-Clause"
] | null | null | null | tools/psp-prxgen.c | erique/pspsdk | e6b7dd27dc044f8b6b05ea0c9494068c29e72e40 | [
"BSD-3-Clause"
] | null | null | null | tools/psp-prxgen.c | erique/pspsdk | e6b7dd27dc044f8b6b05ea0c9494068c29e72e40 | [
"BSD-3-Clause"
] | null | null | null | /*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* psp-prxgen.c - Simple program to build a PRX file (and strip at the same time)
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: psp-prxgen.c 1520 2005-12-04 20:09:36Z tyranid $
*/
#include <stdio.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <ctype.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "types.h"
#include "elftypes.h"
#include "prxtypes.h"
/* Arrangement of ELF file after stripping
*
* ELF Header - 52 bytes
* Program Headers
* .text data
* .data data
* Section Headers
* Relocation data
* Section Header String Table
*
* When stripping the sections remove anything which isn't an allocated section or a relocation section.
* The section string section we will rebuild.
*/
static const char *g_outfile;
static const char *g_infile;
static unsigned char *g_elfdata = NULL;
static struct ElfHeader g_elfhead = {0};
static struct ElfSection *g_elfsections = NULL;
static struct ElfSection *g_modinfo = NULL;
static int g_out_sects = 2;
static int g_alloc_size = 0;
static int g_mem_size = 0;
static int g_reloc_size = 0;
static int g_str_size = 1;
/* Base addresses in the Elf */
static int g_phbase = 0;
static int g_allocbase = 0;
static int g_shbase = 0;
static int g_relocbase = 0;
static int g_shstrbase = 0;
/* Specifies that the current usage is to the print the pspsdk path */
static int g_verbose = 0;
static struct option arg_opts[] =
{
{"verbose", no_argument, NULL, 'v'},
{ NULL, 0, NULL, 0 }
};
/* Process the arguments */
int process_args(int argc, char **argv)
{
int ch;
g_outfile = NULL;
g_infile = NULL;
ch = getopt_long(argc, argv, "v", arg_opts, NULL);
while(ch != -1)
{
switch(ch)
{
case 'v' : g_verbose = 1;
break;
default : break;
};
ch = getopt_long(argc, argv, "v", arg_opts, NULL);
}
argc -= optind;
argv += optind;
if(argc < 2)
{
return 0;
}
g_infile = argv[0];
g_outfile = argv[1];
if(g_verbose)
{
fprintf(stderr, "Loading %s, outputting to %s\n", g_infile, g_outfile);
}
return 1;
}
void print_help(void)
{
fprintf(stderr, "Usage: psp-prxgen [-v] infile.elf outfile.prx\n");
fprintf(stderr, "Options:\n");
fprintf(stderr, "-v, --verbose : Verbose output\n");
}
unsigned char *load_file(const char *file)
{
FILE *fp;
unsigned int size;
unsigned char *data = NULL;
do
{
fp = fopen(file, "rb");
if(fp != NULL)
{
(void) fseek(fp, 0, SEEK_END);
size = ftell(fp);
rewind(fp);
if(size < sizeof(Elf32_Ehdr))
{
fprintf(stderr, "Error, invalid file size\n");
break;
}
data = (unsigned char *) malloc(size);
if(data == NULL)
{
fprintf(stderr, "Error, could not allocate memory for ELF\n");
break;
}
(void) fread(data, 1, size, fp);
fclose(fp);
}
else
{
fprintf(stderr, "Error, could not find file %s\n", file);
}
}
while(0);
return data;
}
/* Validate the ELF header */
int validate_header(unsigned char *data)
{
Elf32_Ehdr *head;
int ret = 0;
head = (Elf32_Ehdr*) data;
do
{
/* Read in the header structure */
g_elfhead.iMagic = LW(head->e_magic);
g_elfhead.iClass = head->e_class;
g_elfhead.iData = head->e_data;
g_elfhead.iIdver = head->e_idver;
g_elfhead.iType = LH(head->e_type);
g_elfhead.iMachine = LH(head->e_machine);
g_elfhead.iVersion = LW(head->e_version);
g_elfhead.iEntry = LW(head->e_entry);
g_elfhead.iPhoff = LW(head->e_phoff);
g_elfhead.iShoff = LW(head->e_shoff);
g_elfhead.iFlags = LW(head->e_flags);
g_elfhead.iEhsize = LH(head->e_ehsize);
g_elfhead.iPhentsize = LH(head->e_phentsize);
g_elfhead.iPhnum = LH(head->e_phnum);
g_elfhead.iShentsize = LH(head->e_shentsize);
g_elfhead.iShnum = LH(head->e_shnum);
g_elfhead.iShstrndx = LH(head->e_shstrndx);
if(g_verbose)
{
fprintf(stderr, "Magic %08X, Class %02X, Data %02X, Idver %02X\n", g_elfhead.iMagic,
g_elfhead.iClass, g_elfhead.iData, g_elfhead.iIdver);
fprintf(stderr, "Type %04X, Machine %04X, Version %08X, Entry %08X\n", g_elfhead.iType,
g_elfhead.iMachine, g_elfhead.iVersion, g_elfhead.iEntry);
fprintf(stderr, "Phoff %08X, Shoff %08X, Flags %08X, Ehsize %08X\n", g_elfhead.iPhoff,
g_elfhead.iShoff, g_elfhead.iFlags, g_elfhead.iEhsize);
fprintf(stderr, "Phentsize %04X, Phnum %04X\n", g_elfhead.iPhentsize, g_elfhead.iPhnum);
fprintf(stderr, "Shentsize %04X, Shnum %08X, Shstrndx %04X\n", g_elfhead.iShentsize,
g_elfhead.iShnum, g_elfhead.iShstrndx);
}
if(g_elfhead.iMagic != ELF_MAGIC)
{
fprintf(stderr, "Error, invalid magic in the header\n");
break;
}
if((g_elfhead.iType != ELF_EXEC_TYPE) && (g_elfhead.iType != ELF_PRX_TYPE))
{
fprintf(stderr, "Error, not EXEC type elf\n");
break;
}
if(g_elfhead.iMachine != ELF_MACHINE_MIPS)
{
fprintf(stderr, "Error, not MIPS type ELF\n");
break;
}
if(g_elfhead.iShnum < g_elfhead.iShstrndx)
{
fprintf(stderr, "Error, number of headers is less than section string index\n");
break;
}
ret = 1;
}
while(0);
return ret;
}
/* Load sections into ram */
int load_sections(unsigned char *data)
{
int ret = 0;
int found_rel = 0;
unsigned int load_addr = 0xFFFFFFFF;
if(g_elfhead.iShnum > 0)
{
do
{
Elf32_Shdr *sect;
int i;
g_elfsections = (struct ElfSection *) malloc(sizeof(struct ElfSection) * g_elfhead.iShnum);
if(g_elfsections == NULL)
{
fprintf(stderr, "Error, could not allocate memory for sections\n");
break;
}
memset(g_elfsections, 0, sizeof(struct ElfSection) * g_elfhead.iShnum);
for(i = 0; i < g_elfhead.iShnum; i++)
{
sect = (Elf32_Shdr *) (g_elfdata + g_elfhead.iShoff + (i * g_elfhead.iShentsize));
g_elfsections[i].iName = LW(sect->sh_name);
g_elfsections[i].iType = LW(sect->sh_type);
g_elfsections[i].iAddr = LW(sect->sh_addr);
g_elfsections[i].iFlags = LW(sect->sh_flags);
g_elfsections[i].iOffset = LW(sect->sh_offset);
g_elfsections[i].iSize = LW(sect->sh_size);
g_elfsections[i].iLink = LW(sect->sh_link);
g_elfsections[i].iInfo = LW(sect->sh_info);
g_elfsections[i].iAddralign = LW(sect->sh_addralign);
g_elfsections[i].iEntsize = LW(sect->sh_entsize);
g_elfsections[i].iIndex = i;
if(g_elfsections[i].iOffset != 0)
{
g_elfsections[i].pData = g_elfdata + g_elfsections[i].iOffset;
}
if(g_elfsections[i].iFlags & SHF_ALLOC)
{
g_elfsections[i].blOutput = 1;
if(g_elfsections[i].iAddr < load_addr)
{
load_addr = g_elfsections[i].iAddr;
}
}
if(((g_elfsections[i].iType == SHT_REL) || (g_elfsections[i].iType == SHT_PRXRELOC))
&& (g_elfsections[g_elfsections[i].iInfo].iFlags & SHF_ALLOC))
{
g_elfsections[i].pRef = &g_elfsections[g_elfsections[i].iInfo];
found_rel = 1;
g_elfsections[i].blOutput = 1;
}
}
/* Okay so we have loaded all the sections, lets fix up the names */
for(i = 0; i < g_elfhead.iShnum; i++)
{
strcpy(g_elfsections[i].szName, (char *) (g_elfsections[g_elfhead.iShstrndx].pData + g_elfsections[i].iName));
if(strcmp(g_elfsections[i].szName, PSP_MODULE_INFO_NAME) == 0)
{
g_modinfo = &g_elfsections[i];
}
else if(strcmp(g_elfsections[i].szName, PSP_MODULE_REMOVE_REL) == 0)
{
/* Don't output .rel.lib.stub relocations */
g_elfsections[i].blOutput = 0;
}
}
if(g_verbose)
{
for(i = 0; i < g_elfhead.iShnum; i++)
{
fprintf(stderr, "\nSection %d: %s\n", i, g_elfsections[i].szName);
fprintf(stderr, "Name %08X, Type %08X, Flags %08X, Addr %08X\n",
g_elfsections[i].iName, g_elfsections[i].iType,
g_elfsections[i].iFlags, g_elfsections[i].iAddr);
fprintf(stderr, "Offset %08X, Size %08X, Link %08X, Info %08X\n",
g_elfsections[i].iOffset, g_elfsections[i].iSize,
g_elfsections[i].iLink, g_elfsections[i].iInfo);
fprintf(stderr, "Addralign %08X, Entsize %08X pData %p\n",
g_elfsections[i].iAddralign, g_elfsections[i].iEntsize,
g_elfsections[i].pData);
}
fprintf(stderr, "ELF Load Base address %08X\n", load_addr);
}
if(g_modinfo == NULL)
{
fprintf(stderr, "Error, no sceModuleInfo section found\n");
break;
}
if(!found_rel)
{
fprintf(stderr, "Error, found no relocation sections\n");
break;
}
if(load_addr != 0)
{
fprintf(stderr, "Error, ELF not loaded to address 0 (%08X)\n", load_addr);
break;
}
ret = 1;
}
while(0);
}
else
{
fprintf(stderr, "Error, no sections in the ELF\n");
}
return ret;
}
int remove_weak_relocs(struct ElfSection *pReloc, struct ElfSection *pSymbol, struct ElfSection *pString)
{
int iCount;
int iMaxSymbol;
void *pNewRel = NULL;
Elf32_Rel *pInRel;
Elf32_Rel *pOutRel;
Elf32_Sym *pSymData = (Elf32_Sym *) pSymbol->pData;
char *pStrData = NULL;
int iOutput;
int i;
if(pString != NULL)
{
pStrData = (char *) pString->pData;
}
iMaxSymbol = pSymbol->iSize / sizeof(Elf32_Sym);
iCount = pReloc->iSize / sizeof(Elf32_Rel);
pNewRel = malloc(pReloc->iSize);
if(pNewRel == NULL)
{
return 0;
}
pOutRel = (Elf32_Rel *) pNewRel;
pInRel = (Elf32_Rel *) pReloc->pData;
iOutput = 0;
if(g_verbose)
{
fprintf(stderr, "[%s] Processing %d relocations, %d symbols\n", pReloc->szName, iCount, iMaxSymbol);
}
for(i = 0; i < iCount; i++)
{
int iSymbol;
iSymbol = ELF32_R_SYM(LW(pInRel->r_info));
if(g_verbose)
{
fprintf(stderr, "Relocation %d - Symbol %x\n", iOutput, iSymbol);
}
if(iSymbol >= iMaxSymbol)
{
fprintf(stderr, "Warning: Ignoring relocation as cannot find matching symbol\n");
}
else
{
if(g_verbose)
{
if(pStrData != NULL)
{
fprintf(stderr, "Symbol %d - Name %s info %x ndx %x\n", iSymbol, &pStrData[pSymData[iSymbol].st_name],
pSymData[iSymbol].st_info, pSymData[iSymbol].st_shndx);
}
else
{
fprintf(stderr, "Symbol %d - Name %d info %x ndx %x\n", iSymbol, pSymData[iSymbol].st_name,
pSymData[iSymbol].st_info, pSymData[iSymbol].st_shndx);
}
}
if(LH(pSymData[iSymbol].st_shndx) == 0)
{
if(g_verbose)
{
fprintf(stderr, "Deleting relocation\n");
}
}
else
{
/* We are keeping this relocation, copy it across */
*pOutRel = *pInRel;
pOutRel++;
iOutput++;
}
}
pInRel++;
}
/* If we deleted some relocations */
if(iOutput < iCount)
{
int iSize;
iSize = iOutput * sizeof(Elf32_Rel);
if(g_verbose)
{
fprintf(stderr, "Old relocation size %d, new %d\n", pReloc->iSize, iSize);
}
pReloc->iSize = iSize;
/* If size is zero then delete this section */
if(iSize == 0)
{
pReloc->blOutput = 0;
}
else
{
/* Copy across the new relocation data */
memcpy(pReloc->pData, pNewRel, pReloc->iSize);
}
}
free(pNewRel);
return 1;
}
/* Let's remove the weak relocations from the list */
int process_relocs(void)
{
int i;
for(i = 0; i < g_elfhead.iShnum; i++)
{
if((g_elfsections[i].blOutput) && (g_elfsections[i].iType == SHT_REL))
{
struct ElfSection *pReloc;
pReloc = &g_elfsections[i];
if((pReloc->iLink < g_elfhead.iShnum) && (g_elfsections[pReloc->iLink].iType == SHT_SYMTAB))
{
struct ElfSection *pStrings = NULL;
struct ElfSection *pSymbols;
pSymbols = &g_elfsections[pReloc->iLink];
if((pSymbols->iLink < g_elfhead.iShnum) && (g_elfsections[pSymbols->iLink].iType == SHT_STRTAB))
{
pStrings = &g_elfsections[pSymbols->iLink];
}
if(!remove_weak_relocs(pReloc, pSymbols, pStrings))
{
return 0;
}
}
else
{
if(g_verbose)
{
fprintf(stderr, "Ignoring relocation section %d, invalid link number\n", i);
}
}
}
}
return 1;
}
/* Reindex the sections we are keeping */
void reindex_sections(void)
{
int i;
int sect = 1;
for(i = 0; i < g_elfhead.iShnum; i++)
{
if(g_elfsections[i].blOutput)
{
g_elfsections[i].iIndex = sect++;
}
}
}
/* Load an ELF file */
int load_elf(const char *elf)
{
int ret = 0;
do
{
g_elfdata = load_file(elf);
if(g_elfdata == NULL)
{
break;
}
if(!validate_header(g_elfdata))
{
break;
}
if(!load_sections(g_elfdata))
{
break;
}
if(!process_relocs())
{
break;
}
reindex_sections();
ret = 1;
}
while(0);
return ret;
}
int calculate_outsize(void)
{
/* out_sects starts at two for the null section and the section string table */
int out_sects = 2;
int alloc_size = 0;
int reloc_size = 0;
int mem_size = 0;
/* 1 for the NUL for the NULL section */
int str_size = 1;
int i;
/* Calculate how big our output file needs to be */
/* We have elf header + 1 PH + allocated data + section headers + relocation data */
/* Note that the ELF should be based from 0, we use this to calculate the alloc and mem sizes */
/* Skip null section */
for(i = 1; i < g_elfhead.iShnum; i++)
{
if(g_elfsections[i].blOutput)
{
if(g_elfsections[i].iType == SHT_PROGBITS)
{
unsigned int top_addr;
top_addr = g_elfsections[i].iAddr + g_elfsections[i].iSize;
if(top_addr > alloc_size)
{
alloc_size = top_addr;
}
if(top_addr > mem_size)
{
mem_size = top_addr;
}
out_sects++;
str_size += strlen(g_elfsections[i].szName) + 1;
}
else if((g_elfsections[i].iType == SHT_REL) || (g_elfsections[i].iType == SHT_PRXRELOC))
{
/* Check this is a reloc for an allocated section */
if(g_elfsections[g_elfsections[i].iInfo].iFlags & SHF_ALLOC)
{
reloc_size += g_elfsections[i].iSize;
out_sects++;
str_size += strlen(g_elfsections[i].szName) + 1;
}
}
else
{
unsigned int top_addr;
top_addr = g_elfsections[i].iAddr + g_elfsections[i].iSize;
if(top_addr > mem_size)
{
mem_size = top_addr;
}
out_sects++;
str_size += strlen(g_elfsections[i].szName) + 1;
}
}
}
alloc_size = (alloc_size + 3) & ~3;
mem_size = (mem_size + 3) & ~3;
str_size = (str_size + 3) & ~3;
str_size += strlen(ELF_SH_STRTAB) + 1;
if(g_verbose)
{
fprintf(stderr, "Out_sects %d, alloc_size %d, reloc_size %d, str_size %d, mem_size %d\n",
out_sects, alloc_size, reloc_size, str_size, mem_size);
}
/* Save them for future use */
g_out_sects = out_sects;
g_alloc_size = alloc_size;
g_reloc_size = reloc_size;
g_mem_size = mem_size;
g_str_size = str_size;
/* Lets build the offsets */
g_phbase = sizeof(Elf32_Ehdr);
/* The allocated data needs to be 16 byte aligned */
g_allocbase = (g_phbase + sizeof(Elf32_Shdr) + 0xF) & ~0xF;
g_shbase = g_allocbase + g_alloc_size;
g_relocbase = g_shbase + (g_out_sects * sizeof(Elf32_Shdr));
g_shstrbase = g_relocbase + g_reloc_size;
if(g_verbose)
{
fprintf(stderr, "PHBase %08X, AllocBase %08X, SHBase %08X\n", g_phbase, g_allocbase, g_shbase);
fprintf(stderr, "Relocbase %08X, Shstrbase %08X\n", g_relocbase, g_shstrbase);
fprintf(stderr, "Total size %d\n", g_shstrbase + g_str_size);
}
return (g_shstrbase + g_str_size);
}
/* Output the ELF header */
void output_header(unsigned char *data)
{
Elf32_Ehdr *head;
head = (Elf32_Ehdr*) data;
SW(&head->e_magic, g_elfhead.iMagic);
head->e_class = g_elfhead.iClass;
head->e_data = g_elfhead.iData;
head->e_idver = g_elfhead.iIdver;
SH(&head->e_type, ELF_PRX_TYPE);
SH(&head->e_machine, g_elfhead.iMachine);
SW(&head->e_version, g_elfhead.iVersion);
SW(&head->e_entry, g_elfhead.iEntry);
SW(&head->e_phoff, g_phbase);
SW(&head->e_shoff, g_shbase);
SW(&head->e_flags, g_elfhead.iFlags);
SH(&head->e_ehsize, sizeof(Elf32_Ehdr));
SH(&head->e_phentsize, sizeof(Elf32_Phdr));
SH(&head->e_phnum, 1);
SH(&head->e_shentsize, sizeof(Elf32_Shdr));
SH(&head->e_shnum, g_out_sects);
SH(&head->e_shstrndx, g_out_sects-1);
}
/* Output the program header */
void output_ph(unsigned char *data)
{
Elf32_Phdr *phdr;
struct PspModuleInfo *pModinfo;
int mod_flags;
phdr = (Elf32_Phdr*) data;
pModinfo = (struct PspModuleInfo *) (g_modinfo->pData);
mod_flags = LW(pModinfo->flags);
SW(&phdr->p_type, 1);
/* Starts after the program header */
SW(&phdr->p_offset, g_allocbase);
SW(&phdr->p_vaddr, 0);
/* Check if this is a kernel module */
if(mod_flags & 0x1000)
{
SW(&phdr->p_paddr, 0x80000000 | (g_modinfo->iAddr + g_allocbase));
}
else
{
SW(&phdr->p_paddr, (g_modinfo->iAddr + g_allocbase));
}
SW(&phdr->p_filesz, g_alloc_size);
SW(&phdr->p_memsz, g_mem_size);
SW(&phdr->p_flags, 5);
SW(&phdr->p_align, 0x10);
}
/* Output the allocated sections */
void output_alloc(unsigned char *data)
{
int i;
for(i = 0; i < g_elfhead.iShnum; i++)
{
if((g_elfsections[i].blOutput) && (g_elfsections[i].iType == SHT_PROGBITS))
{
memcpy(&data[g_elfsections[i].iAddr], g_elfsections[i].pData, g_elfsections[i].iSize);
}
}
}
/* Output the section headers */
void output_sh(unsigned char *data)
{
unsigned int reloc_ofs;
unsigned int str_ofs;
Elf32_Shdr *shdr;
int i;
shdr = (Elf32_Shdr*) data;
/* For the NULL section */
shdr++;
memset(data, 0, g_out_sects * sizeof(Elf32_Shdr));
reloc_ofs = g_relocbase;
str_ofs = 1;
for(i = 1; i < g_elfhead.iShnum; i++)
{
if(g_elfsections[i].blOutput)
{
SW(&shdr->sh_name, str_ofs);
str_ofs += strlen(g_elfsections[i].szName) + 1;
SW(&shdr->sh_flags, g_elfsections[i].iFlags);
SW(&shdr->sh_addr, g_elfsections[i].iAddr);
SW(&shdr->sh_size, g_elfsections[i].iSize);
SW(&shdr->sh_link, 0);
SW(&shdr->sh_addralign, g_elfsections[i].iAddralign);
SW(&shdr->sh_entsize, g_elfsections[i].iEntsize);
if((g_elfsections[i].iType == SHT_REL) || (g_elfsections[i].iType == SHT_PRXRELOC))
{
SW(&shdr->sh_type, SHT_PRXRELOC);
SW(&shdr->sh_info, g_elfsections[i].pRef->iIndex);
SW(&shdr->sh_offset, reloc_ofs);
reloc_ofs += g_elfsections[i].iSize;
}
else if(g_elfsections[i].iType == SHT_PROGBITS)
{
SW(&shdr->sh_type, g_elfsections[i].iType);
SW(&shdr->sh_info, 0);
SW(&shdr->sh_offset, g_allocbase + g_elfsections[i].iAddr);
}
else
{
SW(&shdr->sh_type, g_elfsections[i].iType);
SW(&shdr->sh_info, 0);
/* Point it to the end of the allocated section */
SW(&shdr->sh_offset, g_allocbase + g_alloc_size);
}
shdr++;
}
}
/* Fill in the shstrtab section */
SW(&shdr->sh_name, str_ofs);
SW(&shdr->sh_flags, 0);
SW(&shdr->sh_addr, 0);
SW(&shdr->sh_size, g_str_size);
SW(&shdr->sh_link, 0);
SW(&shdr->sh_addralign, 1);
SW(&shdr->sh_entsize, 0);
SW(&shdr->sh_type, SHT_STRTAB);
SW(&shdr->sh_info, 0);
SW(&shdr->sh_offset, g_shstrbase);
}
/* Output relocations */
void output_relocs(unsigned char *data)
{
int i;
unsigned char *pReloc;
pReloc = data;
for(i = 0; i < g_elfhead.iShnum; i++)
{
if((g_elfsections[i].blOutput) &&
((g_elfsections[i].iType == SHT_REL) || (g_elfsections[i].iType == SHT_PRXRELOC)))
{
Elf32_Rel *rel;
int j, count;
memcpy(pReloc, g_elfsections[i].pData, g_elfsections[i].iSize);
rel = (Elf32_Rel*) pReloc;
count = g_elfsections[i].iSize / sizeof(Elf32_Rel);
for(j = 0; j < count; j++)
{
unsigned int sym;
/* Clear the top 24bits of the info */
/* Kind of a dirty trick but hey :P */
sym = LW(rel->r_info);
sym &= 0xFF;
SW(&rel->r_info, sym);
rel++;
}
pReloc += g_elfsections[i].iSize;
}
}
}
/* Output the section header string table */
void output_shstrtab(unsigned char *data)
{
int i;
char *pData;
/* For the NULL section, memory should be zeroed anyway */
memset(data, 0, g_str_size);
pData = (char *) (data + 1);
for(i = 1; i < g_elfhead.iShnum; i++)
{
if(g_elfsections[i].blOutput)
{
if(g_verbose)
{
fprintf(stderr, "String %d: %s\n", i, g_elfsections[i].szName);
}
strcpy(pData, g_elfsections[i].szName);
pData += strlen(g_elfsections[i].szName) + 1;
}
}
strcpy(pData, ELF_SH_STRTAB);
}
/* Output a stripped prx file */
int output_prx(const char *prxfile)
{
int size;
unsigned char *data;
FILE *fp;
do
{
size = calculate_outsize();
data = (unsigned char *) malloc(size);
if(data == NULL)
{
fprintf(stderr, "Error, couldn't allocate output data\n");
break;
}
memset(data, 0, size);
output_header(data);
output_ph(data + g_phbase);
output_alloc(data + g_allocbase);
output_sh(data + g_shbase);
output_relocs(data + g_relocbase);
output_shstrtab(data + g_shstrbase);
fp = fopen(prxfile, "wb");
if(fp != NULL)
{
fwrite(data, 1, size, fp);
fclose(fp);
}
else
{
fprintf(stderr, "Error, could not open output file %s\n", prxfile);
}
free(data);
}
while(0);
return 0;
}
/* Free allocated memory */
void free_data(void)
{
if(g_elfdata != NULL)
{
free(g_elfdata);
g_elfdata = NULL;
}
if(g_elfsections != NULL)
{
free(g_elfsections);
g_elfsections = NULL;
}
}
int main(int argc, char **argv)
{
if(process_args(argc, argv))
{
if(load_elf(g_infile))
{
(void) output_prx(g_outfile);
free_data();
}
}
else
{
print_help();
}
return 0;
}
| 22.511677 | 114 | 0.645478 |
a9fa90f24ba4ed3eb19343aae00e29d862b396a7 | 6,310 | c | C | Versionen/2021_06_15/RMF/rmf_ws/install/rmf_building_map_msgs/include/rmf_building_map_msgs/msg/detail/place__type_support.c | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | null | null | null | Versionen/2021_06_15/RMF/rmf_ws/install/rmf_building_map_msgs/include/rmf_building_map_msgs/msg/detail/place__type_support.c | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | null | null | null | Versionen/2021_06_15/RMF/rmf_ws/install/rmf_building_map_msgs/include/rmf_building_map_msgs/msg/detail/place__type_support.c | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | 2 | 2021-06-21T07:32:09.000Z | 2021-08-17T03:05:38.000Z | // generated from rosidl_typesupport_introspection_c/resource/idl__type_support.c.em
// with input from rmf_building_map_msgs:msg/Place.idl
// generated code does not contain a copyright notice
#include <stddef.h>
#include "rmf_building_map_msgs/msg/detail/place__rosidl_typesupport_introspection_c.h"
#include "rmf_building_map_msgs/msg/rosidl_typesupport_introspection_c__visibility_control.h"
#include "rosidl_typesupport_introspection_c/field_types.h"
#include "rosidl_typesupport_introspection_c/identifier.h"
#include "rosidl_typesupport_introspection_c/message_introspection.h"
#include "rmf_building_map_msgs/msg/detail/place__functions.h"
#include "rmf_building_map_msgs/msg/detail/place__struct.h"
// Include directives for member types
// Member `name`
#include "rosidl_runtime_c/string_functions.h"
#ifdef __cplusplus
extern "C"
{
#endif
void Place__rosidl_typesupport_introspection_c__Place_init_function(
void * message_memory, enum rosidl_runtime_c__message_initialization _init)
{
// TODO(karsten1987): initializers are not yet implemented for typesupport c
// see https://github.com/ros2/ros2/issues/397
(void) _init;
rmf_building_map_msgs__msg__Place__init(message_memory);
}
void Place__rosidl_typesupport_introspection_c__Place_fini_function(void * message_memory)
{
rmf_building_map_msgs__msg__Place__fini(message_memory);
}
static rosidl_typesupport_introspection_c__MessageMember Place__rosidl_typesupport_introspection_c__Place_message_member_array[6] = {
{
"name", // name
rosidl_typesupport_introspection_c__ROS_TYPE_STRING, // type
0, // upper bound of string
NULL, // members of sub message
false, // is array
0, // array size
false, // is upper bound
offsetof(rmf_building_map_msgs__msg__Place, name), // bytes offset in struct
NULL, // default value
NULL, // size() function pointer
NULL, // get_const(index) function pointer
NULL, // get(index) function pointer
NULL // resize(index) function pointer
},
{
"x", // name
rosidl_typesupport_introspection_c__ROS_TYPE_FLOAT, // type
0, // upper bound of string
NULL, // members of sub message
false, // is array
0, // array size
false, // is upper bound
offsetof(rmf_building_map_msgs__msg__Place, x), // bytes offset in struct
NULL, // default value
NULL, // size() function pointer
NULL, // get_const(index) function pointer
NULL, // get(index) function pointer
NULL // resize(index) function pointer
},
{
"y", // name
rosidl_typesupport_introspection_c__ROS_TYPE_FLOAT, // type
0, // upper bound of string
NULL, // members of sub message
false, // is array
0, // array size
false, // is upper bound
offsetof(rmf_building_map_msgs__msg__Place, y), // bytes offset in struct
NULL, // default value
NULL, // size() function pointer
NULL, // get_const(index) function pointer
NULL, // get(index) function pointer
NULL // resize(index) function pointer
},
{
"yaw", // name
rosidl_typesupport_introspection_c__ROS_TYPE_FLOAT, // type
0, // upper bound of string
NULL, // members of sub message
false, // is array
0, // array size
false, // is upper bound
offsetof(rmf_building_map_msgs__msg__Place, yaw), // bytes offset in struct
NULL, // default value
NULL, // size() function pointer
NULL, // get_const(index) function pointer
NULL, // get(index) function pointer
NULL // resize(index) function pointer
},
{
"position_tolerance", // name
rosidl_typesupport_introspection_c__ROS_TYPE_FLOAT, // type
0, // upper bound of string
NULL, // members of sub message
false, // is array
0, // array size
false, // is upper bound
offsetof(rmf_building_map_msgs__msg__Place, position_tolerance), // bytes offset in struct
NULL, // default value
NULL, // size() function pointer
NULL, // get_const(index) function pointer
NULL, // get(index) function pointer
NULL // resize(index) function pointer
},
{
"yaw_tolerance", // name
rosidl_typesupport_introspection_c__ROS_TYPE_FLOAT, // type
0, // upper bound of string
NULL, // members of sub message
false, // is array
0, // array size
false, // is upper bound
offsetof(rmf_building_map_msgs__msg__Place, yaw_tolerance), // bytes offset in struct
NULL, // default value
NULL, // size() function pointer
NULL, // get_const(index) function pointer
NULL, // get(index) function pointer
NULL // resize(index) function pointer
}
};
static const rosidl_typesupport_introspection_c__MessageMembers Place__rosidl_typesupport_introspection_c__Place_message_members = {
"rmf_building_map_msgs__msg", // message namespace
"Place", // message name
6, // number of fields
sizeof(rmf_building_map_msgs__msg__Place),
Place__rosidl_typesupport_introspection_c__Place_message_member_array, // message members
Place__rosidl_typesupport_introspection_c__Place_init_function, // function to initialize message memory (memory has to be allocated)
Place__rosidl_typesupport_introspection_c__Place_fini_function // function to terminate message instance (will not free memory)
};
// this is not const since it must be initialized on first access
// since C does not allow non-integral compile-time constants
static rosidl_message_type_support_t Place__rosidl_typesupport_introspection_c__Place_message_type_support_handle = {
0,
&Place__rosidl_typesupport_introspection_c__Place_message_members,
get_message_typesupport_handle_function,
};
ROSIDL_TYPESUPPORT_INTROSPECTION_C_EXPORT_rmf_building_map_msgs
const rosidl_message_type_support_t *
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, rmf_building_map_msgs, msg, Place)() {
if (!Place__rosidl_typesupport_introspection_c__Place_message_type_support_handle.typesupport_identifier) {
Place__rosidl_typesupport_introspection_c__Place_message_type_support_handle.typesupport_identifier =
rosidl_typesupport_introspection_c__identifier;
}
return &Place__rosidl_typesupport_introspection_c__Place_message_type_support_handle;
}
#ifdef __cplusplus
}
#endif
| 39.192547 | 136 | 0.752298 |
aa66e0c3fa6ff36a5a69afd7f68cdd6a466744b0 | 1,644 | h | C | src/lib/crypt_ops/compat_openssl.h | 47-studio-org/-.-M3-0N-.- | 2344e854cb46942e573bb342cd76808c5819fd9e | [
"BSD-2-Clause-NetBSD"
] | 2 | 2021-09-08T18:47:51.000Z | 2021-11-16T11:28:46.000Z | src/lib/crypt_ops/compat_openssl.h | 47-studio-org/-.-M3-0N-.- | 2344e854cb46942e573bb342cd76808c5819fd9e | [
"BSD-2-Clause-NetBSD"
] | null | null | null | src/lib/crypt_ops/compat_openssl.h | 47-studio-org/-.-M3-0N-.- | 2344e854cb46942e573bb342cd76808c5819fd9e | [
"BSD-2-Clause-NetBSD"
] | 1 | 2021-03-16T01:53:19.000Z | 2021-03-16T01:53:19.000Z | /* Copyright (c) 2001, Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_COMPAT_OPENSSL_H
#define TOR_COMPAT_OPENSSL_H
#include "orconfig.h"
#ifdef ENABLE_OPENSSL
#include <openssl/opensslv.h>
#include "lib/crypt_ops/crypto_openssl_mgt.h"
/**
* \file compat_openssl.h
*
* \brief compatibility definitions for working with different openssl forks
**/
#if !defined(LIBRESSL_VERSION_NUMBER) && \
OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(1,0,1)
#error "We require OpenSSL >= 1.0.1"
#endif
#if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0) && \
! defined(LIBRESSL_VERSION_NUMBER)
/* We define this macro if we're trying to build with the majorly refactored
* API in OpenSSL 1.1 */
#define OPENSSL_1_1_API
#endif /* OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0) && ... */
#ifndef OPENSSL_1_1_API
#define OpenSSL_version(v) SSLeay_version(v)
#define tor_OpenSSL_version_num() SSLeay()
#define RAND_OpenSSL() RAND_SSLeay()
#define STATE_IS_SW_SERVER_HELLO(st) \
(((st) == SSL3_ST_SW_SRVR_HELLO_A) || \
((st) == SSL3_ST_SW_SRVR_HELLO_B))
#define OSSL_HANDSHAKE_STATE int
#define CONST_IF_OPENSSL_1_1_API
#else /* defined(OPENSSL_1_1_API) */
#define tor_OpenSSL_version_num() OpenSSL_version_num()
#define STATE_IS_SW_SERVER_HELLO(st) \
((st) == TLS_ST_SW_SRVR_HELLO)
#define CONST_IF_OPENSSL_1_1_API const
#endif /* !defined(OPENSSL_1_1_API) */
#endif /* defined(ENABLE_OPENSSL) */
#endif /* !defined(TOR_COMPAT_OPENSSL_H) */
| 30.444444 | 76 | 0.748175 |
c87b3772f3eb632712966b9a58975e04e26f0f71 | 145 | h | C | cuda/cuda_omp45_coexisting/kernels.h | TApplencourt/FGPU | a6a93229af25589ffdaf98c08c590772c5369216 | [
"BSD-3-Clause"
] | 31 | 2019-03-18T23:55:19.000Z | 2022-01-07T08:37:48.000Z | cuda/cuda_omp45_coexisting/kernels.h | TApplencourt/FGPU | a6a93229af25589ffdaf98c08c590772c5369216 | [
"BSD-3-Clause"
] | 6 | 2019-03-13T20:33:03.000Z | 2021-11-15T17:02:49.000Z | cuda/cuda_omp45_coexisting/kernels.h | LLNL/FGPU | cf1c651771bcf55449614f62eab057f25c44c35b | [
"BSD-3-Clause"
] | 14 | 2019-05-24T17:22:36.000Z | 2022-01-07T08:40:34.000Z | // In saxpy.cuf
extern "C" void testsaxpy_cudafortran();
// In saxpy.cu
void testSaxpy_cudac(void);
// In saxpy.c
void testdaxpy_omp45(void);
| 14.5 | 40 | 0.724138 |
c8f3010760fcd08cb5526753cb1c06f0614c94ee | 1,376 | h | C | psx/octoshock/psx/input/dualshock.h | Fortranm/BizHawk | 8cb0ffb6f8964cc339bbe1784838918fb0aa7e27 | [
"MIT"
] | 1,414 | 2015-06-28T09:57:51.000Z | 2021-10-14T03:51:10.000Z | psx/octoshock/psx/input/dualshock.h | Fortranm/BizHawk | 8cb0ffb6f8964cc339bbe1784838918fb0aa7e27 | [
"MIT"
] | 2,369 | 2015-06-25T01:45:44.000Z | 2021-10-16T08:44:18.000Z | psx/octoshock/psx/input/dualshock.h | Fortranm/BizHawk | 8cb0ffb6f8964cc339bbe1784838918fb0aa7e27 | [
"MIT"
] | 430 | 2015-06-29T04:28:58.000Z | 2021-10-05T18:24:17.000Z | /******************************************************************************/
/* Mednafen Sony PS1 Emulation Module */
/******************************************************************************/
/* dualshock.h:
** Copyright (C) 2012-2016 Mednafen Team
**
** This program 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.
**
** This program 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 this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MDFN_PSX_INPUT_DUALSHOCK_H
#define __MDFN_PSX_INPUT_DUALSHOCK_H
#include "octoshock.h"
namespace MDFN_IEN_PSX
{
InputDevice *Device_DualShock_Create();
EW_PACKED(
struct IO_Dualshock
{
u8 buttons[3];
u8 right_x, right_y;
u8 left_x, left_y;
u8 active;
u8 pad[8];
u8 pad2[3];
u16 rumble;
u8 pad3[11];
});
}
#endif
| 29.276596 | 80 | 0.62718 |
ece1b01fd26b94e181ec126f2a22b60abcd399be | 2,117 | h | C | extensions/common/feature_switch.h | cvsuser-chromium/chromium | acb8e8e4a7157005f527905b48dd48ddaa3b863a | [
"BSD-3-Clause"
] | 4 | 2017-04-05T01:51:34.000Z | 2018-02-15T03:11:54.000Z | extensions/common/feature_switch.h | cvsuser-chromium/chromium | acb8e8e4a7157005f527905b48dd48ddaa3b863a | [
"BSD-3-Clause"
] | 1 | 2021-12-13T19:44:12.000Z | 2021-12-13T19:44:12.000Z | extensions/common/feature_switch.h | cvsuser-chromium/chromium | acb8e8e4a7157005f527905b48dd48ddaa3b863a | [
"BSD-3-Clause"
] | 4 | 2017-04-05T01:52:03.000Z | 2022-02-13T17:58:45.000Z | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_COMMON_FEATURE_SWITCH_H_
#define EXTENSIONS_COMMON_FEATURE_SWITCH_H_
#include <string>
#include "base/basictypes.h"
class CommandLine;
namespace extensions {
// A switch that can turn a feature on or off. Typically controlled via
// command-line switches but can be overridden, e.g., for testing.
class FeatureSwitch {
public:
static FeatureSwitch* easy_off_store_install();
static FeatureSwitch* global_commands();
static FeatureSwitch* script_badges();
static FeatureSwitch* script_bubble();
static FeatureSwitch* prompt_for_external_extensions();
static FeatureSwitch* error_console();
enum DefaultValue {
DEFAULT_ENABLED,
DEFAULT_DISABLED
};
enum OverrideValue {
OVERRIDE_NONE,
OVERRIDE_ENABLED,
OVERRIDE_DISABLED
};
// A temporary override for the switch value.
class ScopedOverride {
public:
ScopedOverride(FeatureSwitch* feature, bool override_value);
~ScopedOverride();
private:
FeatureSwitch* feature_;
FeatureSwitch::OverrideValue previous_value_;
DISALLOW_COPY_AND_ASSIGN(ScopedOverride);
};
FeatureSwitch(const char* switch_name,
DefaultValue default_value);
FeatureSwitch(const CommandLine* command_line,
const char* switch_name,
DefaultValue default_value);
// Consider using ScopedOverride instead.
void SetOverrideValue(OverrideValue value);
OverrideValue GetOverrideValue() const;
bool IsEnabled() const;
std::string GetLegacyEnableFlag() const;
std::string GetLegacyDisableFlag() const;
private:
void Init(const CommandLine* command_line,
const char* switch_name,
DefaultValue default_value);
const CommandLine* command_line_;
const char* switch_name_;
bool default_value_;
OverrideValue override_value_;
DISALLOW_COPY_AND_ASSIGN(FeatureSwitch);
};
} // namespace extensions
#endif // EXTENSIONS_COMMON_FEATURE_SWITCH_H_
| 26.4625 | 73 | 0.747756 |
7f4991c4f556cfe4b87427ccfcdaa5ab6807211d | 9,437 | c | C | portable/oWatcom/16BitDOS/common/portcomn.c | Asif198788/FreeRTOS-Kernel | ffb83cbaaedcefecaba3c9f5e6956c92a9140f6f | [
"MIT"
] | null | null | null | portable/oWatcom/16BitDOS/common/portcomn.c | Asif198788/FreeRTOS-Kernel | ffb83cbaaedcefecaba3c9f5e6956c92a9140f6f | [
"MIT"
] | 1 | 2022-01-16T02:06:11.000Z | 2022-01-16T02:06:11.000Z | portable/oWatcom/16BitDOS/common/portcomn.c | Asif198788/FreeRTOS-Kernel | ffb83cbaaedcefecaba3c9f5e6956c92a9140f6f | [
"MIT"
] | null | null | null | <<<<<<< HEAD
/*
* FreeRTOS Kernel <DEVELOPMENT BRANCH>
* Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
/*
Changes from V1.00:
+ pxPortInitialiseStack() now initialises the stack of new tasks to the
same format used by the compiler. This allows the compiler generated
interrupt mechanism to be used for context switches.
Changes from V2.4.2:
+ pvPortMalloc and vPortFree have been removed. The projects now use
the definitions from the source/portable/MemMang directory.
Changes from V2.6.1:
+ usPortCheckFreeStackSpace() has been moved to tasks.c.
*/
#include <stdlib.h>
#include "FreeRTOS.h"
/*-----------------------------------------------------------*/
/* See header file for description. */
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
{
StackType_t DS_Reg = 0, *pxOriginalSP;
/* Place a few bytes of known values on the bottom of the stack.
This is just useful for debugging. */
*pxTopOfStack = 0x1111;
pxTopOfStack--;
*pxTopOfStack = 0x2222;
pxTopOfStack--;
*pxTopOfStack = 0x3333;
pxTopOfStack--;
*pxTopOfStack = 0x4444;
pxTopOfStack--;
*pxTopOfStack = 0x5555;
pxTopOfStack--;
/*lint -e950 -e611 -e923 Lint doesn't like this much - but nothing I can do about it. */
/* We are going to start the scheduler using a return from interrupt
instruction to load the program counter, so first there would be the
status register and interrupt return address. We make this the start
of the task. */
*pxTopOfStack = portINITIAL_SW;
pxTopOfStack--;
*pxTopOfStack = FP_SEG( pxCode );
pxTopOfStack--;
*pxTopOfStack = FP_OFF( pxCode );
pxTopOfStack--;
/* We are going to setup the stack for the new task to look like
the stack frame was setup by a compiler generated ISR. We need to know
the address of the existing stack top to place in the SP register within
the stack frame. pxOriginalSP holds SP before (simulated) pusha was
called. */
pxOriginalSP = pxTopOfStack;
/* The remaining registers would be pushed on the stack by our context
switch function. These are loaded with values simply to make debugging
easier. */
*pxTopOfStack = FP_OFF( pvParameters ); /* AX */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xCCCC; /* CX */
pxTopOfStack--;
*pxTopOfStack = FP_SEG( pvParameters ); /* DX */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xBBBB; /* BX */
pxTopOfStack--;
*pxTopOfStack = FP_OFF( pxOriginalSP ); /* SP */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xBBBB; /* BP */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0x0123; /* SI */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xDDDD; /* DI */
/* We need the true data segment. */
__asm{ MOV DS_Reg, DS };
pxTopOfStack--;
*pxTopOfStack = DS_Reg; /* DS */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xEEEE; /* ES */
/* The AX register is pushed again twice - don't know why. */
pxTopOfStack--;
*pxTopOfStack = FP_OFF( pvParameters ); /* AX */
pxTopOfStack--;
*pxTopOfStack = FP_OFF( pvParameters ); /* AX */
#ifdef DEBUG_BUILD
/* The compiler adds space to each ISR stack if building to
include debug information. Presumably this is used by the
debugger - we don't need to initialise it to anything just
make sure it is there. */
pxTopOfStack--;
#endif
/*lint +e950 +e611 +e923 */
return pxTopOfStack;
}
/*-----------------------------------------------------------*/
=======
/*
* FreeRTOS SMP Kernel V202110.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
* 1 tab == 4 spaces!
*/
/*
Changes from V1.00:
+ pxPortInitialiseStack() now initialises the stack of new tasks to the
same format used by the compiler. This allows the compiler generated
interrupt mechanism to be used for context switches.
Changes from V2.4.2:
+ pvPortMalloc and vPortFree have been removed. The projects now use
the definitions from the source/portable/MemMang directory.
Changes from V2.6.1:
+ usPortCheckFreeStackSpace() has been moved to tasks.c.
*/
#include <stdlib.h>
#include "FreeRTOS.h"
/*-----------------------------------------------------------*/
/* See header file for description. */
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
{
StackType_t DS_Reg = 0, *pxOriginalSP;
/* Place a few bytes of known values on the bottom of the stack.
This is just useful for debugging. */
*pxTopOfStack = 0x1111;
pxTopOfStack--;
*pxTopOfStack = 0x2222;
pxTopOfStack--;
*pxTopOfStack = 0x3333;
pxTopOfStack--;
*pxTopOfStack = 0x4444;
pxTopOfStack--;
*pxTopOfStack = 0x5555;
pxTopOfStack--;
/*lint -e950 -e611 -e923 Lint doesn't like this much - but nothing I can do about it. */
/* We are going to start the scheduler using a return from interrupt
instruction to load the program counter, so first there would be the
status register and interrupt return address. We make this the start
of the task. */
*pxTopOfStack = portINITIAL_SW;
pxTopOfStack--;
*pxTopOfStack = FP_SEG( pxCode );
pxTopOfStack--;
*pxTopOfStack = FP_OFF( pxCode );
pxTopOfStack--;
/* We are going to setup the stack for the new task to look like
the stack frame was setup by a compiler generated ISR. We need to know
the address of the existing stack top to place in the SP register within
the stack frame. pxOriginalSP holds SP before (simulated) pusha was
called. */
pxOriginalSP = pxTopOfStack;
/* The remaining registers would be pushed on the stack by our context
switch function. These are loaded with values simply to make debugging
easier. */
*pxTopOfStack = FP_OFF( pvParameters ); /* AX */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xCCCC; /* CX */
pxTopOfStack--;
*pxTopOfStack = FP_SEG( pvParameters ); /* DX */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xBBBB; /* BX */
pxTopOfStack--;
*pxTopOfStack = FP_OFF( pxOriginalSP ); /* SP */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xBBBB; /* BP */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0x0123; /* SI */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xDDDD; /* DI */
/* We need the true data segment. */
__asm{ MOV DS_Reg, DS };
pxTopOfStack--;
*pxTopOfStack = DS_Reg; /* DS */
pxTopOfStack--;
*pxTopOfStack = ( StackType_t ) 0xEEEE; /* ES */
/* The AX register is pushed again twice - don't know why. */
pxTopOfStack--;
*pxTopOfStack = FP_OFF( pvParameters ); /* AX */
pxTopOfStack--;
*pxTopOfStack = FP_OFF( pvParameters ); /* AX */
#ifdef DEBUG_BUILD
/* The compiler adds space to each ISR stack if building to
include debug information. Presumably this is used by the
debugger - we don't need to initialise it to anything just
make sure it is there. */
pxTopOfStack--;
#endif
/*lint +e950 +e611 +e923 */
return pxTopOfStack;
}
/*-----------------------------------------------------------*/
>>>>>>> origin/smp
| 32.881533 | 107 | 0.690368 |
fa3b7b1d8c2b28a8f7a74c2551daa97a2e54694b | 5,526 | h | C | hphp/util/multibitset.h | jeffomatic/hhvm | afd1a0c089aff36a31b8990490366606694a2842 | [
"PHP-3.01",
"Zend-2.0"
] | 7 | 2015-08-28T06:20:50.000Z | 2021-11-08T09:48:24.000Z | hphp/util/multibitset.h | alisha/hhvm | 523dc33b444bd5b59695eff2b64056629b0ed523 | [
"PHP-3.01",
"Zend-2.0"
] | 2 | 2020-10-11T22:54:12.000Z | 2021-07-20T22:12:10.000Z | hphp/util/multibitset.h | alisha/hhvm | 523dc33b444bd5b59695eff2b64056629b0ed523 | [
"PHP-3.01",
"Zend-2.0"
] | 3 | 2018-01-23T20:44:59.000Z | 2021-05-06T12:45:31.000Z | /*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_UTIL_MULTIBITSET_H_
#define incl_HPHP_UTIL_MULTIBITSET_H_
#include <cstddef>
#include <cstdint>
#include <limits>
#include <unordered_map>
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
/*
* Like a bitset, but we have N bits at each position instead of 1.
*/
template<size_t N>
struct multibitset {
/*
* Create an empty multibitset with no bits allocated.
*/
multibitset();
/*
* Allocate a multibitset with room for `nelms' N-bits, and zero it.
*/
explicit multibitset(size_t nelms);
/*
* Free the allocated bits.
*/
~multibitset();
/*
* Make room for `nelms' N-bits in the set, shrinking it if `nelms' is
* smaller than the current size.
*/
void resize(size_t nelms);
/*
* Set all N-bits to zero.
*/
void reset();
/////////////////////////////////////////////////////////////////////////////
/*
* Reference to an N-bit.
*
* Behaves analogously to std::bitset::reference.
*/
struct reference {
/* implicit */ operator uint64_t() const;
reference& operator=(uint64_t);
friend struct multibitset<N>;
private:
reference(multibitset<N>& mbs, size_t pos);
private:
multibitset<N>& m_mbs;
size_t m_word;
uint8_t m_bit;
};
static constexpr size_t npos = std::numeric_limits<uint64_t>::max();
/////////////////////////////////////////////////////////////////////////////
/*
* Access a specific N-bit.
*
* This asserts that `pos <= N'; as such, we do not implement a test().
*/
uint64_t operator[](size_t pos) const;
reference operator[](size_t pos);
/*
* Returns the number of N-bits the multibitset can hold.
*/
size_t size() const;
/*
* Find the position of the first or last N-bit set to a nonzero value,
* starting at `pos'. Note that `pos' is an inclusive bound, so `pos' itself
* may be returned.
*
* Returns `npos' if no set N-bit is found.
*/
size_t ffs(size_t pos = 0) const;
size_t fls(size_t pos = npos) const;
/////////////////////////////////////////////////////////////////////////////
private:
static_assert(N > 0 && N < 64, "must have 0 < N < 64");
private:
uint64_t* m_bits{nullptr};
size_t m_size{0};
size_t m_nwords{0};
};
template<size_t N>
constexpr size_t multibitset<N>::npos;
///////////////////////////////////////////////////////////////////////////////
/*
* An alternate multibitset interface intended for use patterns with sparse
* clusters of marked bits.
*
* Has roughly the same interface as multibitset, with exceptions noted.
*/
template<size_t N>
struct chunked_multibitset {
/*
* Create an empty multibitset.
*
* chunked_multibitset automatically expands storage as bits are set. Thus,
* it does not accept a size restriction; instead, it takes a chunk size.
*/
explicit chunked_multibitset(size_t chunk_sz);
/////////////////////////////////////////////////////////////////////////////
struct reference {
/* implicit */ operator uint64_t() const;
reference& operator=(uint64_t);
friend struct chunked_multibitset<N>;
private:
reference(chunked_multibitset<N>& cmbs, size_t pos);
private:
chunked_multibitset<N>& m_cmbs;
size_t m_pos;
};
static constexpr size_t npos = std::numeric_limits<uint64_t>::max();
/////////////////////////////////////////////////////////////////////////////
void reset();
/*
* Return a reference to an N-bit.
*
* Setting an N-bit may cause new chunks to be allocated.
*/
uint64_t operator[](size_t pos) const;
reference operator[](size_t pos);
/*
* Find set bit; see multibitset::f{f,l}s().
*
* The time complexity of these routines is linearly bounded by the number of
* chunks in which bits have been touched during the lifetime of the object.
* No other guarantees are made.
*/
size_t ffs(size_t pos = 0) const;
size_t fls(size_t pos = npos) const;
/////////////////////////////////////////////////////////////////////////////
private:
static_assert(N > 0 && N <= 64, "must have 0 < N <= 64");
multibitset<N>& chunk_for(size_t pos);
private:
std::unordered_map<size_t,multibitset<N>> m_chunks;
const size_t m_chunk_sz;
size_t m_highwater{0};
size_t m_lowwater{npos};
};
template<size_t N>
constexpr size_t chunked_multibitset<N>::npos;
///////////////////////////////////////////////////////////////////////////////
}
#include "hphp/util/multibitset-inl.h"
#endif
| 26.956098 | 79 | 0.529678 |
36af21a84fea318317d7066b369c3082ef6cd666 | 5,287 | c | C | Drivers/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_q7_q15_reordered.c | robgal519/MT_uart1_HAL | 70d2c7fd0c5f3f6752aad9905b25847dc032da90 | [
"MIT"
] | 128 | 2018-10-29T04:11:47.000Z | 2022-03-07T02:19:14.000Z | Drivers/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_q7_q15_reordered.c | robgal519/MT_uart1_HAL | 70d2c7fd0c5f3f6752aad9905b25847dc032da90 | [
"MIT"
] | 68 | 2020-04-29T08:52:39.000Z | 2022-03-25T08:55:25.000Z | Drivers/CMSIS/NN/Source/ConvolutionFunctions/arm_nn_mat_mult_kernel_q7_q15_reordered.c | robgal519/MT_uart1_HAL | 70d2c7fd0c5f3f6752aad9905b25847dc032da90 | [
"MIT"
] | 118 | 2018-10-29T08:43:57.000Z | 2022-01-07T06:49:25.000Z | /*
* Copyright (C) 2010-2018 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* ----------------------------------------------------------------------
* Project: CMSIS NN Library
* Title: arm_nn_mat_mult_kernel_q7_q15_reordered.c
* Description: Matrix-multiplication function for convolution with reordered columns
*
* $Date: 17. January 2018
* $Revision: V.1.0.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
#include "arm_nnfunctions.h"
#include "arm_math.h"
/**
* @brief Matrix-multiplication function for convolution with reordered columns
* @param[in] pA pointer to operand A
* @param[in] pInBuffer pointer to operand B, always conssists of 2 vectors
* @param[in] ch_im_out numRow of A
* @param[in] numCol_A numCol of A
* @param[in] bias_shift amount of left-shift for bias
* @param[in] out_shift amount of right-shift for output
* @param[in] bias the bias
* @param[in,out] pOut pointer to output
* @return The function returns the incremented output pointer
*
* @details
*
* This function assumes that data in pInBuffer are reordered
*/
q7_t *arm_nn_mat_mult_kernel_q7_q15_reordered(const q7_t * pA,
const q15_t * pInBuffer,
const uint16_t ch_im_out,
const uint16_t numCol_A,
const uint16_t bias_shift,
const uint16_t out_shift,
const q7_t * bias,
q7_t * pOut)
{
#if defined (ARM_MATH_DSP)
/* set up the second output pointers */
q7_t *pOut2 = pOut + ch_im_out;
int i;
/* this loop over rows in A */
for (i = 0; i < ch_im_out; i += 2)
{
/* setup pointers for B */
const q15_t *pB = pInBuffer;
const q15_t *pB2 = pB + numCol_A;
/* align the second pointer for A */
const q7_t *pA2 = pA + numCol_A;
/* init the sum with bias */
q31_t sum = ((q31_t)(bias[i]) << bias_shift) + NN_ROUND(out_shift);
q31_t sum2 = ((q31_t)(bias[i]) << bias_shift) + NN_ROUND(out_shift);
q31_t sum3 = ((q31_t)(bias[i + 1]) << bias_shift) + NN_ROUND(out_shift);
q31_t sum4 = ((q31_t)(bias[i + 1]) << bias_shift) + NN_ROUND(out_shift);
uint16_t colCnt = numCol_A >> 2;
/* accumulate over the vector */
while (colCnt)
{
q31_t inA11, inA12, inA21, inA22;
q31_t inB1 = *__SIMD32(pB)++;
q31_t inB2 = *__SIMD32(pB2)++;
pA = (q7_t *) read_and_pad_reordered((void *)pA, &inA11, &inA12);
pA2 = (q7_t *) read_and_pad_reordered((void *)pA2, &inA21, &inA22);
sum = __SMLAD(inA11, inB1, sum);
sum2 = __SMLAD(inA11, inB2, sum2);
sum3 = __SMLAD(inA21, inB1, sum3);
sum4 = __SMLAD(inA21, inB2, sum4);
inB1 = *__SIMD32(pB)++;
inB2 = *__SIMD32(pB2)++;
sum = __SMLAD(inA12, inB1, sum);
sum2 = __SMLAD(inA12, inB2, sum2);
sum3 = __SMLAD(inA22, inB1, sum3);
sum4 = __SMLAD(inA22, inB2, sum4);
colCnt--;
} /* while over colCnt */
colCnt = numCol_A & 0x3;
while (colCnt)
{
q7_t inA1 = *pA++;
q15_t inB1 = *pB++;
q7_t inA2 = *pA2++;
q15_t inB2 = *pB2++;
sum += inA1 * inB1;
sum2 += inA1 * inB2;
sum3 += inA2 * inB1;
sum4 += inA2 * inB2;
colCnt--;
} /* while over colCnt */
*pOut++ = (q7_t) __SSAT((sum >> out_shift), 8);
*pOut++ = (q7_t) __SSAT((sum3 >> out_shift), 8);
*pOut2++ = (q7_t) __SSAT((sum2 >> out_shift), 8);
*pOut2++ = (q7_t) __SSAT((sum4 >> out_shift), 8);
/* skip the row computed with A2 */
pA += numCol_A;
} /* for over ch_im_out */
pOut += ch_im_out;
/* return the new output pointer with offset */
return pOut;
#else
/* To be completed */
return NULL;
#endif /* ARM_MATH_DSP */
}
| 38.035971 | 87 | 0.497825 |
3221de469bff8f2d9b0f96733a5d50a120db85ff | 7,281 | h | C | src/public/dispcoll.h | cstom4994/SourceEngineRebuild | edfd7f8ce8af13e9d23586318350319a2e193c08 | [
"MIT"
] | 6 | 2022-01-23T09:40:33.000Z | 2022-03-20T20:53:25.000Z | src/public/dispcoll.h | cstom4994/SourceEngineRebuild | edfd7f8ce8af13e9d23586318350319a2e193c08 | [
"MIT"
] | null | null | null | src/public/dispcoll.h | cstom4994/SourceEngineRebuild | edfd7f8ce8af13e9d23586318350319a2e193c08 | [
"MIT"
] | 1 | 2022-02-06T21:05:23.000Z | 2022-02-06T21:05:23.000Z | //========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DISPCOLL_H
#define DISPCOLL_H
#pragma once
#include "mathlib/vector.h"
class CCoreDispInfo;
//=============================================================================
//
// Displacement Collision Triangle Data
//
class CDispCollTri
{
public:
void Init( void );
inline void SetPoint( int index, Vector const& vert );
inline void SetPointNormal( int index, Vector const& normal );
void CalcPlane( void );
inline void SetIntersect( bool bIntersect );
inline bool IsIntersect( void );
Vector m_Points[3]; // polygon points
Vector m_PointNormals[3]; // polygon point normals
Vector m_Normal; // plane normal
float m_Distance; // plane distance
short m_ProjAxes[2]; // projection axes (2 minor axes)
bool m_bIntersect; // intersected triangle???
};
//=============================================================================
//
// Displacement Collision Node Data
//
class CDispCollNode
{
public:
CDispCollNode();
inline bool IsLeaf( void );
inline void SetBounds( Vector const &bMin, Vector const &bMax );
inline void GetBounds( Vector &bMin, Vector &bMax );
Vector m_Bounds[2]; // node minimum and maximum
bool m_bIsLeaf; // is the node a leaf? ( may have to make this an int for alignment!)
CDispCollTri m_Tris[2]; // two triangles contained in leaf node
};
//=============================================================================
//
// Displacement Collision Data
//
class CDispCollData
{
public:
Vector m_StartPos;
Vector m_EndPos;
Vector m_Extents;
float m_Fraction;
int m_Contents;
Vector m_Normal;
float m_Distance;
bool m_bOcclude;
};
// HACKHACK: JAY: Moved this out of CDispCollTree to be thread safe in vrad
enum { TRILIST_CACHE_SIZE = 128 };
class CDispCollTreeTempData
{
public:
//
// temps
//
int m_TriListCount;
CDispCollTri *m_ppTriList[TRILIST_CACHE_SIZE];
// collision tree node cache
float m_AABBDistances[6];
};
//=============================================================================
//
// Displacement Collision Tree
//
class CDispCollTree
{
public:
static const float COLLISION_EPSILON;
static const float ONE_MINUS_COLLISION_EPSILON;
//=========================================================================
//
// Creation/Destruction
//
CDispCollTree();
~CDispCollTree();
virtual bool Create( CCoreDispInfo *pDisp );
//=========================================================================
//
// Collision Functions
//
bool RayTest( CDispCollData *pData );
bool RayTestAllTris( CDispCollData *pData, int power );
bool AABBIntersect( CDispCollData *pData );
bool AABBSweep( CDispCollData *pData );
//=========================================================================
//
// Attrib Functions
//
inline void SetPower( int power );
inline int GetPower( void );
inline void SetCheckCount( int count );
inline int GetCheckCount( void );
inline void GetBounds( Vector& boundMin, Vector& boundMax );
protected:
int m_Power;
int m_NodeCount;
CDispCollNode *m_pNodes;
int m_CheckCount;
// collision tree node cache
Vector m_AABBNormals[6];
//=========================================================================
//
// Creation/Destruction
//
void InitAABBData( void );
void InitLeaves( CCoreDispInfo *pDisp );
void CreateNodes( CCoreDispInfo *pDisp );
void CreateNodes_r( CCoreDispInfo *pDisp, int nodeIndex, int termLevel );
void CalcBounds( CDispCollNode *pNode, int nodeIndex );
//=========================================================================
//
// Collision Functions
//
void CreatePlanesFromBounds( CDispCollTreeTempData *pTemp, Vector const &bbMin, Vector const &bbMax );
// void RayNodeTest_r( int nodeIndex, Vector &rayStart, Vector &rayEnd );
void RayNodeTest_r( CDispCollTreeTempData *pTemp, int nodeIndex, Vector rayStart, Vector rayEnd );
bool RayAABBTest( CDispCollTreeTempData *pTemp, Vector &rayStart, Vector &rayEnd );
bool RayTriListTest( CDispCollTreeTempData *pTemp, CDispCollData *pData );
bool RayTriTest( Vector const &rayStart, Vector const &rayDir, float const rayLength, CDispCollTri const *pTri, float *fraction );
void BuildTriList_r( CDispCollTreeTempData *pTemp, int nodeIndex, Vector &rayStart, Vector &rayEnd, Vector &extents, bool bIntersect );
bool IntersectAABBAABBTest( CDispCollTreeTempData *pTemp, const Vector &pos, const Vector &extents );
bool SweptAABBAABBTest( CDispCollTreeTempData *pTemp, const Vector &rayStart, const Vector &rayEnd, const Vector &extents );
bool CullTriList( CDispCollTreeTempData *pTemp, Vector &rayStart, Vector &rayEnd, Vector &extents, bool bIntersect );
bool SweptAABBTriTest( Vector &rayStart, Vector &rayEnd, Vector &extents, CDispCollTri const *pTri );
bool AABBTriIntersect( CDispCollTreeTempData *pTemp, CDispCollData *pData );
bool IntersectAABBTriTest( Vector &rayStart, Vector &extents, CDispCollTri const *pTri );
bool SweptAABBTriIntersect( Vector &rayStart, Vector &rayEnd, Vector &extents,
CDispCollTri const *pTri, Vector &plNormal, float *plDist,
float *fraction );
//=========================================================================
//
// Memory Functions
//
bool AllocNodes( int nodeCount );
void FreeNodes( void );
//=========================================================================
//
// Utility Functions
//
inline int CalcNodeCount( int power );
inline int GetParentNode( int nodeIndex );
inline int GetChildNode( int nodeIndex, int direction );
inline int GetNodeLevel( int nodeIndex );
int GetNodeIndexFromComponents( int x, int y );
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline void CDispCollTree::SetPower( int power )
{
m_Power = power;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline int CDispCollTree::GetPower( void )
{
return m_Power;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline void CDispCollTree::SetCheckCount( int count )
{
m_CheckCount = count;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline int CDispCollTree::GetCheckCount( void )
{
return m_CheckCount;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
inline void CDispCollTree::GetBounds( Vector& boundMin, Vector& boundMax )
{
boundMin[0] = m_pNodes[0].m_Bounds[0].x;
boundMin[1] = m_pNodes[0].m_Bounds[0].y;
boundMin[2] = m_pNodes[0].m_Bounds[0].z;
boundMax[0] = m_pNodes[0].m_Bounds[1].x;
boundMax[1] = m_pNodes[0].m_Bounds[1].y;
boundMax[2] = m_pNodes[0].m_Bounds[1].z;
}
#endif // DISPCOLL_H | 29.240964 | 136 | 0.553907 |
9a6983eeb3d9ff7513b518db1ad844dabe84fa8b | 2,662 | h | C | sdl_core/src/thirdPartyLibs/apache-log4cxx-win32-0.10.0/apache-log4cxx-0.10.0/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h | APCVSRepo/android_packet | 5d4237234656b777cd9b0cae4731afea51986582 | [
"BSD-3-Clause"
] | 4 | 2016-09-21T12:36:24.000Z | 2020-10-29T01:45:03.000Z | sdl_core/src/thirdPartyLibs/apache-log4cxx-win32-0.10.0/apache-log4cxx-0.10.0/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h | APCVSRepo/android_packet | 5d4237234656b777cd9b0cae4731afea51986582 | [
"BSD-3-Clause"
] | 7 | 2016-06-01T01:21:44.000Z | 2017-11-03T08:18:23.000Z | sdl_core/src/thirdPartyLibs/apache-log4cxx-win32-0.10.0/apache-log4cxx-0.10.0/src/main/include/log4cxx/rolling/manualtriggeringpolicy.h | APCVSRepo/android_packet | 5d4237234656b777cd9b0cae4731afea51986582 | [
"BSD-3-Clause"
] | 8 | 2017-08-29T10:51:50.000Z | 2021-03-24T10:19:11.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined(_LOG4CXX_ROLLING_MANUAL_TRIGGERING_POLICY_H)
#define _LOG4CXX_ROLLING_MANUAL_TRIGGERING_POLICY_H
#include <log4cxx/rolling/triggeringpolicy.h>
namespace log4cxx {
class File;
namespace helpers {
class Pool;
}
namespace rolling {
/**
* ManualTriggeringPolicy only rolls over on explicit calls to
* RollingFileAppender.rollover().
*
*
*
*/
class LOG4CXX_EXPORT ManualTriggeringPolicy : public TriggeringPolicy {
DECLARE_LOG4CXX_OBJECT(ManualTriggeringPolicy)
BEGIN_LOG4CXX_CAST_MAP()
LOG4CXX_CAST_ENTRY(ManualTriggeringPolicy)
LOG4CXX_CAST_ENTRY_CHAIN(TriggeringPolicy)
END_LOG4CXX_CAST_MAP()
public:
ManualTriggeringPolicy();
/**
* Determines if a rollover may be appropriate at this time. If
* true is returned, RolloverPolicy.rollover will be called but it
* can determine that a rollover is not warranted.
*
* @param appender A reference to the appender.
* @param event A reference to the currently event.
* @param filename The filename for the currently active log file.
* @param fileLength Length of the file in bytes.
* @return true if a rollover should occur.
*/
virtual bool isTriggeringEvent(
Appender* appender,
const log4cxx::spi::LoggingEventPtr& event,
const LogString& filename,
size_t fileLength);
void activateOptions(log4cxx::helpers::Pool&);
void setOption(const LogString& option, const LogString& value);
};
}
}
#endif
| 36.465753 | 80 | 0.637115 |
3c347e4b47b153bd203ce2c95d241759c36caf6f | 5,861 | c | C | jni/proj4/src/pj_initcache.c | maru2020/RtkGps | 11bd70de57c1548f2b76a7ded06fc92057e21863 | [
"BSD-2-Clause"
] | 162 | 2015-01-11T09:30:42.000Z | 2022-03-31T20:12:33.000Z | jni/proj4/src/pj_initcache.c | maru2020/RtkGps | 11bd70de57c1548f2b76a7ded06fc92057e21863 | [
"BSD-2-Clause"
] | 41 | 2015-02-10T10:23:32.000Z | 2021-11-18T03:14:48.000Z | jni/proj4/src/pj_initcache.c | maru2020/RtkGps | 11bd70de57c1548f2b76a7ded06fc92057e21863 | [
"BSD-2-Clause"
] | 115 | 2015-01-24T21:08:29.000Z | 2022-02-12T08:58:09.000Z | /******************************************************************************
* Project: PROJ.4
* Purpose: init file definition cache.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2009, Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
#include <string.h>
#include "projects.h"
static int cache_count = 0;
static int cache_alloc = 0;
static char **cache_key = NULL;
static paralist **cache_paralist = NULL;
/************************************************************************/
/* pj_clone_paralist() */
/* */
/* Allocate a copy of a parameter list. */
/************************************************************************/
paralist *pj_clone_paralist( const paralist *list)
{
paralist *list_copy = NULL, *next_copy = NULL;
for( ; list != NULL; list = list->next )
{
paralist *newitem = (paralist *)
pj_malloc(sizeof(paralist) + strlen(list->param));
newitem->used = 0;
newitem->next = 0;
strcpy( newitem->param, list->param );
if( list_copy == NULL )
list_copy = newitem;
else
next_copy->next = newitem;
next_copy = newitem;
}
return list_copy;
}
/************************************************************************/
/* pj_clear_initcache() */
/* */
/* Clear out all memory held in the init file cache. */
/************************************************************************/
void pj_clear_initcache()
{
if( cache_alloc > 0 )
{
int i;
pj_acquire_lock();
for( i = 0; i < cache_count; i++ )
{
paralist *n, *t = cache_paralist[i];
pj_dalloc( cache_key[i] );
/* free parameter list elements */
for (; t != NULL; t = n) {
n = t->next;
pj_dalloc(t);
}
}
pj_dalloc( cache_key );
pj_dalloc( cache_paralist );
cache_count = 0;
cache_alloc= 0;
cache_key = NULL;
cache_paralist = NULL;
pj_release_lock();
}
}
/************************************************************************/
/* pj_search_initcache() */
/* */
/* Search for a matching definition in the init cache. */
/************************************************************************/
paralist *pj_search_initcache( const char *filekey )
{
int i;
paralist *result = NULL;
pj_acquire_lock();
for( i = 0; result == NULL && i < cache_count; i++)
{
if( strcmp(filekey,cache_key[i]) == 0 )
{
result = pj_clone_paralist( cache_paralist[i] );
}
}
pj_release_lock();
return result;
}
/************************************************************************/
/* pj_insert_initcache() */
/* */
/* Insert a paralist definition in the init file cache. */
/************************************************************************/
void pj_insert_initcache( const char *filekey, const paralist *list )
{
pj_acquire_lock();
/*
** Grow list if required.
*/
if( cache_count == cache_alloc )
{
char **cache_key_new;
paralist **cache_paralist_new;
cache_alloc = cache_alloc * 2 + 15;
cache_key_new = (char **) pj_malloc(sizeof(char*) * cache_alloc);
if( cache_key && cache_count )
{
memcpy( cache_key_new, cache_key, sizeof(char*) * cache_count);
}
pj_dalloc( cache_key );
cache_key = cache_key_new;
cache_paralist_new = (paralist **)
pj_malloc(sizeof(paralist*) * cache_alloc);
if( cache_paralist && cache_count )
{
memcpy( cache_paralist_new, cache_paralist,
sizeof(paralist*) * cache_count );
}
pj_dalloc( cache_paralist );
cache_paralist = cache_paralist_new;
}
/*
** Duplicate the filekey and paralist, and insert in cache.
*/
cache_key[cache_count] = (char *) pj_malloc(strlen(filekey)+1);
strcpy( cache_key[cache_count], filekey );
cache_paralist[cache_count] = pj_clone_paralist( list );
cache_count++;
pj_release_lock();
}
| 31.681081 | 79 | 0.478246 |
19298b76c22897025f2f83b6ca924cd2d66b2d88 | 540 | h | C | sensors/private_include/sc030iot.h | WangYuxin-esp/esp32-camera | 1ac48e5397ee22a59a18a314c4acf44c23dfe946 | [
"Apache-2.0"
] | null | null | null | sensors/private_include/sc030iot.h | WangYuxin-esp/esp32-camera | 1ac48e5397ee22a59a18a314c4acf44c23dfe946 | [
"Apache-2.0"
] | null | null | null | sensors/private_include/sc030iot.h | WangYuxin-esp/esp32-camera | 1ac48e5397ee22a59a18a314c4acf44c23dfe946 | [
"Apache-2.0"
] | null | null | null | /*
*
* SC030IOT DVP driver.
*
*/
#ifndef __SC030IOT_H__
#define __SC030IOT_H__
#include "sensor.h"
/**
* @brief Detect sensor pid
*
* @param slv_addr SCCB address
* @param id Detection result
* @return
* 0: Can't detect this sensor
* Nonzero: This sensor has been detected
*/
int sc030iot_detect(int slv_addr, sensor_id_t *id);
/**
* @brief initialize sensor function pointers
*
* @param sensor pointer of sensor
* @return
* Always 0
*/
int sc030iot_init(sensor_t *sensor);
#endif // __SC030IOT_H__
| 16.875 | 51 | 0.672222 |
30714073e340633a75f14c9a45a57c07ead047ba | 3,336 | h | C | cryptoTools/Common/Matrix.h | fboemer/cryptoTools | 16a3aa60a1fd1092766a52ead5d780c52b3e39fb | [
"Unlicense"
] | null | null | null | cryptoTools/Common/Matrix.h | fboemer/cryptoTools | 16a3aa60a1fd1092766a52ead5d780c52b3e39fb | [
"Unlicense"
] | null | null | null | cryptoTools/Common/Matrix.h | fboemer/cryptoTools | 16a3aa60a1fd1092766a52ead5d780c52b3e39fb | [
"Unlicense"
] | null | null | null | #pragma once
#ifdef ENABLE_FULL_GSL
#include <cryptoTools/gsl/multi_span>
#else
#include <cryptoTools/gsl/gls-lite.hpp>
#endif
#include <cryptoTools/Common/Defines.h>
#include <cryptoTools/Common/MatrixView.h>
namespace osuCrypto
{
enum class AllocType
{
Uninitialized,
Zeroed
};
template<typename T>
class Matrix : public MatrixView<T>
{
u64 mCapacity = 0;
public:
Matrix() = default;
Matrix(u64 rows, u64 columns, AllocType t = AllocType::Zeroed)
{
resize(rows, columns, t);
}
Matrix(const Matrix<T>& copy)
: MatrixView<T>(new T[copy.size()], copy.bounds()[0], copy.stride())
, mCapacity(copy.size())
{
memcpy(MatrixView<T>::mView.data(), copy.data(), copy.mView.size_bytes());
}
Matrix(const MatrixView<T>& copy)
: MatrixView<T>(new T[copy.size()], copy.bounds()[0], copy.stride())
, mCapacity(copy.size())
{
memcpy(MatrixView<T>::mView.data(), copy.data(), copy.size() * sizeof(T));
}
Matrix(Matrix<T>&& copy)
: MatrixView<T>(copy.data(), copy.bounds()[0], copy.stride())
, mCapacity(copy.mCapacity)
{
copy.mView = span<T>();
copy.mStride = 0;
copy.mCapacity = 0;
}
~Matrix()
{
delete[] MatrixView<T>::mView.data();
}
const Matrix<T>& operator=(const Matrix<T>& copy)
{
resize(copy.rows(), copy.stride());
memcpy(MatrixView<T>::mView.data(), copy.data(), copy.mView.size_bytes());
return copy;
}
void resize(u64 rows, u64 columns, AllocType type = AllocType::Zeroed)
{
if (rows * columns > mCapacity)
{
mCapacity = rows * columns;
auto old = MatrixView<T>::mView;
if (type == AllocType::Zeroed)
MatrixView<T>::mView = span<T>(new T[mCapacity](), mCapacity);
else
MatrixView<T>::mView = span<T>(new T[mCapacity], mCapacity);
auto min = std::min<u64>(old.size(), mCapacity) * sizeof(T);
if(min)
memcpy(MatrixView<T>::mView.data(), old.data(), min);
delete[] old.data();
}
else
{
auto newSize = rows * columns;
if (MatrixView<T>::size() && newSize > MatrixView<T>::size() && type == AllocType::Zeroed)
{
memset(MatrixView<T>::data() + MatrixView<T>::size(), 0, newSize - MatrixView<T>::size());
}
MatrixView<T>::mView = span<T>(MatrixView<T>::data(), newSize);
}
MatrixView<T>::mStride = columns;
}
// return the internal memory, stop managing its lifetime, and set the current container to null.
T* release()
{
auto ret = MatrixView<T>::mView.data();
MatrixView<T>::mView = span<T>(nullptr, 0);
mCapacity = 0;
return ret;
}
};
}
| 28.512821 | 111 | 0.481715 |
a959510752c3997fafae60a011c8d8d6b30792e5 | 7,116 | h | C | include/QuotasSQL.h | rdiaz-on/one | 4b7f47c7e218dd9aea1b4eb79db5725450bc5644 | [
"Apache-2.0"
] | null | null | null | include/QuotasSQL.h | rdiaz-on/one | 4b7f47c7e218dd9aea1b4eb79db5725450bc5644 | [
"Apache-2.0"
] | null | null | null | include/QuotasSQL.h | rdiaz-on/one | 4b7f47c7e218dd9aea1b4eb79db5725450bc5644 | [
"Apache-2.0"
] | null | null | null | /* -------------------------------------------------------------------------- */
/* Copyright 2002-2020, OpenNebula Project, OpenNebula Systems */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
#ifndef GROUP_QUOTAS_H_
#define GROUP_QUOTAS_H_
#include "Quotas.h"
#include "ObjectSQL.h"
class QuotasSQL : public Quotas, ObjectSQL
{
public:
/**
* Reads the ObjectSQL (identified with its OID) from the database.
* @param oid the Group/User oid
* @param db pointer to the db
* @return 0 on success
*/
int select(int _oid, SqlDB *db)
{
oid = _oid;
return select(db);
};
/**
* Writes the Quotas in the database.
* @param db pointer to the db
* @return 0 on success
*/
int insert(int _oid, SqlDB *db, string& error_str)
{
oid = _oid;
return insert(db, error_str);
};
/**
* Writes/updates the Quotas fields in the database.
* @param db pointer to the db
* @return 0 on success
*/
int update(int _oid, SqlDB *db)
{
oid = _oid;
return update(db);
}
/**
* Removes the Quotas from the database.
* @param db pointer to the db
* @return 0 on success
*/
int drop(SqlDB * db);
protected:
QuotasSQL(const char * ds_xpath,
const char * net_xpath,
const char * img_xpath,
const char * vm_xpath):
Quotas(ds_xpath, net_xpath, img_xpath, vm_xpath, false),
ObjectSQL(),
oid(-1){};
virtual ~QuotasSQL(){};
virtual const char * table() const = 0;
virtual const char * table_names() const = 0;
virtual const char * table_oid_column() const = 0;
int from_xml(const string& xml);
private:
/**
* User/Group oid. Must be set before a DB write operation
*/
int oid;
/**
* Reads the ObjectSQL (identified with its OID) from the database.
* @param db pointer to the db
* @return 0 on success
*/
int select(SqlDB * db);
/**
* Writes the Quotas in the database.
* @param db pointer to the db
* @return 0 on success
*/
int insert(SqlDB *db, string& error_str)
{
return insert_replace(db, false, error_str);
};
/**
* Writes/updates the Quotas fields in the database.
* @param db pointer to the db
* @return 0 on success
*/
int update(SqlDB *db)
{
string error_str;
return insert_replace(db, true, error_str);
}
/**
* Callback function to read a Quotas object (Quotas::select)
* @param num the number of columns read from the DB
* @para names the column names
* @para vaues the column values
* @return 0 on success
*/
int select_cb(void *nil, int num, char **values, char **names);
/**
* Execute an INSERT or REPLACE Sql query.
* @param db The SQL DB
* @param replace Execute an INSERT or a REPLACE
* @param error_str Returns the error reason, if any
* @return 0 one success
*/
int insert_replace(SqlDB *db, bool replace, string& error_str);
/**
* Generates a string representation of the quotas in XML format, enclosed
* in the QUOTAS tag
* @param xml the string to store the XML
* @return the same xml string to use it in << compounds
*/
string& to_xml_db(string& xml) const;
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class GroupQuotas : public QuotasSQL
{
public:
GroupQuotas():QuotasSQL(
"/QUOTAS/DATASTORE_QUOTA",
"/QUOTAS/NETWORK_QUOTA",
"/QUOTAS/IMAGE_QUOTA",
"/QUOTAS/VM_QUOTA"){};
virtual ~GroupQuotas(){};
/**
* Bootstraps the database table for group quotas
* @return 0 on success
*/
static int bootstrap(SqlDB * db)
{
ostringstream oss_quota(GroupQuotas::db_bootstrap);
return db->exec_local_wr(oss_quota);
};
protected:
const char * table() const
{
return db_table;
};
const char * table_names() const
{
return db_names;
};
const char * table_oid_column() const
{
return db_oid_column;
};
private:
friend class GroupPool;
// *************************************************************************
// DataBase implementation
// *************************************************************************
static const char * db_names;
static const char * db_bootstrap;
static const char * db_table;
static const char * db_oid_column;
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class UserQuotas : public QuotasSQL
{
public:
UserQuotas():QuotasSQL(
"/QUOTAS/DATASTORE_QUOTA",
"/QUOTAS/NETWORK_QUOTA",
"/QUOTAS/IMAGE_QUOTA",
"/QUOTAS/VM_QUOTA"){};
/**
* Bootstraps the database table for user quotas
* @return 0 on success
*/
static int bootstrap(SqlDB * db)
{
ostringstream oss_quota(UserQuotas::db_bootstrap);
return db->exec_local_wr(oss_quota);
};
protected:
const char * table() const
{
return db_table;
};
const char * table_names() const
{
return db_names;
};
const char * table_oid_column() const
{
return db_oid_column;
};
private:
friend class UserPool;
// *************************************************************************
// DataBase implementation
// *************************************************************************
static const char * db_names;
static const char * db_bootstrap;
static const char * db_table;
static const char * db_oid_column;
};
#endif /*QUOTAS_SQL_H_*/
| 27.688716 | 80 | 0.493676 |
6560f50e208e6b5599f74db36623d93267bc2077 | 4,009 | h | C | RecoTracker/MkFit/plugins/convertHits.h | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 1 | 2021-11-30T16:24:46.000Z | 2021-11-30T16:24:46.000Z | RecoTracker/MkFit/plugins/convertHits.h | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 4 | 2021-11-29T13:57:56.000Z | 2022-03-29T06:28:36.000Z | RecoTracker/MkFit/plugins/convertHits.h | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 1 | 2022-02-27T06:12:26.000Z | 2022-02-27T06:12:26.000Z | #ifndef RecoTracker_MkFit_plugins_convertHits_h
#define RecoTracker_MkFit_plugins_convertHits_h
#include "DataFormats/Provenance/interface/ProductID.h"
#include "FWCore/Utilities/interface/Likely.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "DataFormats/TrackerCommon/interface/TrackerDetSide.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
#include "RecoTracker/MkFit/interface/MkFitGeometry.h"
// ROOT
#include "Math/SVector.h"
#include "Math/SMatrix.h"
// mkFit includes
#include "RecoTracker/MkFitCore/interface/Hit.h"
#include "RecoTracker/MkFitCore/interface/HitStructures.h"
namespace mkfit {
template <typename Traits, typename HitCollection>
edm::ProductID convertHits(const Traits& traits,
const HitCollection& hits,
mkfit::HitVec& mkFitHits,
std::vector<TrackingRecHit const*>& clusterIndexToHit,
std::vector<float>& clusterChargeVec,
const TrackerTopology& ttopo,
const TransientTrackingRecHitBuilder& ttrhBuilder,
const MkFitGeometry& mkFitGeom) {
if (hits.empty())
return edm::ProductID{};
edm::ProductID clusterID;
{
const auto& lastClusterRef = hits.data().back().firstClusterRef();
clusterID = lastClusterRef.id();
if (lastClusterRef.index() >= mkFitHits.size()) {
auto const size = lastClusterRef.index();
mkFitHits.resize(size);
clusterIndexToHit.resize(size, nullptr);
if constexpr (Traits::applyCCC()) {
clusterChargeVec.resize(size, -1.f);
}
}
}
for (const auto& detset : hits) {
const DetId detid = detset.detId();
const auto ilay = mkFitGeom.mkFitLayerNumber(detid);
for (const auto& hit : detset) {
const auto charge = traits.clusterCharge(hit, detid);
if (!traits.passCCC(charge))
continue;
const auto& gpos = hit.globalPosition();
SVector3 pos(gpos.x(), gpos.y(), gpos.z());
const auto& gerr = hit.globalPositionError();
SMatrixSym33 err;
err.At(0, 0) = gerr.cxx();
err.At(1, 1) = gerr.cyy();
err.At(2, 2) = gerr.czz();
err.At(0, 1) = gerr.cyx();
err.At(0, 2) = gerr.czx();
err.At(1, 2) = gerr.czy();
auto clusterRef = hit.firstClusterRef();
if UNLIKELY (clusterRef.id() != clusterID) {
throw cms::Exception("LogicError")
<< "Input hit collection has Refs to many cluster collections. Last hit had Ref to product " << clusterID
<< ", but encountered Ref to product " << clusterRef.id() << " on detid " << detid.rawId();
}
const auto clusterIndex = clusterRef.index();
LogTrace("MkFitHitConverter") << "Adding hit detid " << detid.rawId() << " subdet " << detid.subdetId()
<< " layer " << ttopo.layer(detid) << " isStereo " << ttopo.isStereo(detid)
<< " zplus "
<< " index " << clusterIndex << " ilay " << ilay;
if UNLIKELY (clusterIndex >= mkFitHits.size()) {
mkFitHits.resize(clusterIndex + 1);
clusterIndexToHit.resize(clusterIndex + 1, nullptr);
if constexpr (Traits::applyCCC()) {
clusterChargeVec.resize(clusterIndex + 1, -1.f);
}
}
mkFitHits[clusterIndex] = mkfit::Hit(pos, err);
clusterIndexToHit[clusterIndex] = &hit;
if constexpr (Traits::applyCCC()) {
clusterChargeVec[clusterIndex] = charge;
}
const auto uniqueIdInLayer = mkFitGeom.uniqueIdInLayer(ilay, detid.rawId());
traits.setDetails(mkFitHits[clusterIndex], *(hit.cluster()), uniqueIdInLayer, charge);
}
}
return clusterID;
}
} // namespace mkfit
#endif
| 38.548077 | 119 | 0.5999 |
6597c0182c34983d6938f2bb74ffc3251e4c1aab | 8,739 | c | C | main/ssd1306_spi.c | neocode-mura/TTGO_Camera_v2 | f6ae3742a3fab3947ca8a2d9d210f01ea403ce60 | [
"Apache-2.0"
] | null | null | null | main/ssd1306_spi.c | neocode-mura/TTGO_Camera_v2 | f6ae3742a3fab3947ca8a2d9d210f01ea403ce60 | [
"Apache-2.0"
] | null | null | null | main/ssd1306_spi.c | neocode-mura/TTGO_Camera_v2 | f6ae3742a3fab3947ca8a2d9d210f01ea403ce60 | [
"Apache-2.0"
] | null | null | null | #include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <driver/spi_master.h>
#include <driver/gpio.h>
#include "esp_log.h"
#include "ssd1306.h"
#include "font8x8_basic.h"
#define tag "SSD1306"
static const int GPIO_MOSI = 13;
static const int GPIO_SCLK = 14;
static const int SPI_Command_Mode = 0;
static const int SPI_Data_Mode = 1;
static const int SPI_Frequency = 1000000;
void spi_master_init(SSD1306_t * dev, int GPIO_CS, int GPIO_DC, int GPIO_RESET)
{
esp_err_t ret;
gpio_pad_select_gpio( GPIO_CS );
gpio_set_direction( GPIO_CS, GPIO_MODE_OUTPUT );
gpio_set_level( GPIO_CS, 0 );
gpio_pad_select_gpio( GPIO_DC );
gpio_set_direction( GPIO_DC, GPIO_MODE_OUTPUT );
gpio_set_level( GPIO_DC, 0 );
if ( GPIO_RESET >= 0 ) {
gpio_pad_select_gpio( GPIO_RESET );
gpio_set_direction( GPIO_RESET, GPIO_MODE_OUTPUT );
gpio_set_level( GPIO_RESET, 0 );
vTaskDelay( pdMS_TO_TICKS( 100 ) );
gpio_set_level( GPIO_RESET, 1 );
}
spi_bus_config_t spi_bus_config = {
.sclk_io_num = GPIO_SCLK,
.mosi_io_num = GPIO_MOSI,
.miso_io_num = -1,
.quadwp_io_num = -1,
.quadhd_io_num = -1
};
ret = spi_bus_initialize( HSPI_HOST, &spi_bus_config, 1 );
ESP_LOGI(tag, "spi_bus_initialize=%d",ret);
assert(ret==ESP_OK);
spi_device_interface_config_t devcfg;
memset( &devcfg, 0, sizeof( spi_device_interface_config_t ) );
devcfg.clock_speed_hz = SPI_Frequency;
devcfg.spics_io_num = GPIO_CS;
devcfg.queue_size = 1;
spi_device_handle_t handle;
ret = spi_bus_add_device( HSPI_HOST, &devcfg, &handle);
ESP_LOGI(tag, "spi_bus_add_device=%d",ret);
assert(ret==ESP_OK);
dev->_dc = GPIO_DC;
dev->_SPIHandle = handle;
}
bool spi_master_write_byte(spi_device_handle_t SPIHandle, const uint8_t* Data, size_t DataLength )
{
spi_transaction_t SPITransaction;
if ( DataLength > 0 ) {
memset( &SPITransaction, 0, sizeof( spi_transaction_t ) );
SPITransaction.length = DataLength * 8;
SPITransaction.tx_buffer = Data;
spi_device_transmit( SPIHandle, &SPITransaction );
}
return true;
}
bool spi_master_write_command(SSD1306_t * dev, uint8_t Command )
{
static uint8_t CommandByte = 0;
CommandByte = Command;
gpio_set_level( dev->_dc, SPI_Command_Mode );
return spi_master_write_byte( dev->_SPIHandle, &CommandByte, 1 );
}
bool spi_master_write_data(SSD1306_t * dev, const uint8_t* Data, size_t DataLength )
{
gpio_set_level( dev->_dc, SPI_Data_Mode );
return spi_master_write_byte( dev->_SPIHandle, Data, DataLength );
}
void spi_init(SSD1306_t * dev, int width, int height)
{
dev->_address = SPIAddress;
dev->_width = width;
dev->_height = height;
dev->_pages = 8;
if (dev->_height == 32) dev->_pages = 4;
spi_master_write_command(dev, OLED_CMD_DISPLAY_OFF); // AE
spi_master_write_command(dev, OLED_CMD_SET_MUX_RATIO); // A8
if (dev->_height == 64) spi_master_write_command(dev, 0x3F);
if (dev->_height == 32) spi_master_write_command(dev, 0x1F);
spi_master_write_command(dev, OLED_CMD_SET_DISPLAY_OFFSET); // D3
spi_master_write_command(dev, 0x00);
spi_master_write_command(dev, OLED_CONTROL_BYTE_DATA_STREAM); // 40
spi_master_write_command(dev, OLED_CMD_SET_SEGMENT_REMAP); // A1
spi_master_write_command(dev, OLED_CMD_SET_COM_SCAN_MODE); // C8
spi_master_write_command(dev, OLED_CMD_DISPLAY_NORMAL); // A6
spi_master_write_command(dev, OLED_CMD_SET_DISPLAY_CLK_DIV); // D5
spi_master_write_command(dev, 0x80);
spi_master_write_command(dev, OLED_CMD_SET_COM_PIN_MAP); // DA
if (dev->_height == 64) spi_master_write_command(dev, 0x12);
if (dev->_height == 32) spi_master_write_command(dev, 0x02);
spi_master_write_command(dev, OLED_CMD_SET_CONTRAST); // 81
spi_master_write_command(dev, 0xFF);
spi_master_write_command(dev, OLED_CMD_DISPLAY_RAM); // A4
spi_master_write_command(dev, OLED_CMD_SET_VCOMH_DESELCT); // DB
spi_master_write_command(dev, 0x40);
spi_master_write_command(dev, OLED_CMD_SET_MEMORY_ADDR_MODE); // 20
//spi_master_write_command(dev, OLED_CMD_SET_HORI_ADDR_MODE); // 00
spi_master_write_command(dev, OLED_CMD_SET_PAGE_ADDR_MODE); // 02
// Set Lower Column Start Address for Page Addressing Mode
spi_master_write_command(dev, 0x00);
// Set Higher Column Start Address for Page Addressing Mode
spi_master_write_command(dev, 0x10);
spi_master_write_command(dev, OLED_CMD_SET_CHARGE_PUMP); // 8D
spi_master_write_command(dev, 0x14);
spi_master_write_command(dev, OLED_CMD_DEACTIVE_SCROLL); // 2E
spi_master_write_command(dev, OLED_CMD_DISPLAY_NORMAL); // A6
spi_master_write_command(dev, OLED_CMD_DISPLAY_ON); // AF
}
void spi_display_text(SSD1306_t * dev, int page, char * text, int text_len, bool invert)
{
if (page >= dev->_pages) return;
int _text_len = text_len;
if (_text_len > 16) _text_len = 16;
uint8_t seg = 0;
uint8_t image[8];
for (uint8_t i = 0; i < _text_len; i++) {
memcpy(image, font8x8_basic_tr[(uint8_t)text[i]], 8);
if (invert) ssd1306_invert(image, 8);
spi_display_image(dev, page, seg, image, 8);
#if 0
for(int j=0;j<8;j++)
dev->_page[page]._segs[seg+j] = image[j];
#endif
seg = seg + 8;
}
}
void spi_display_image(SSD1306_t * dev, int page, int seg, uint8_t * images, int width)
{
if (page >= dev->_pages) return;
if (seg >= dev->_width) return;
uint8_t columLow = seg & 0x0F;
uint8_t columHigh = (seg >> 4) & 0x0F;
// Set Lower Column Start Address for Page Addressing Mode
//i2c_master_write_byte(cmd, 0x00, true);
spi_master_write_command(dev, (0x00 + columLow));
// Set Higher Column Start Address for Page Addressing Mode
//spi_master_write_command(dev, 0x10, 1);
spi_master_write_command(dev, (0x10 + columHigh));
// Set Page Start Address for Page Addressing Mode
spi_master_write_command(dev, 0xB0 | page);
spi_master_write_data(dev, images, width);
}
void spi_contrast(SSD1306_t * dev, int contrast) {
int _contrast = contrast;
if (contrast < 0x0) _contrast = 0;
if (contrast > 0xFF) _contrast = 0xFF;
spi_master_write_command(dev, OLED_CMD_SET_CONTRAST); // 81
spi_master_write_command(dev, _contrast);
}
void spi_hardware_scroll(SSD1306_t * dev, ssd1306_scroll_type_t scroll)
{
if (scroll == SCROLL_RIGHT) {
spi_master_write_command(dev, OLED_CMD_HORIZONTAL_RIGHT); // 26
spi_master_write_command(dev, 0x00); // Dummy byte
spi_master_write_command(dev, 0x00); // Define start page address
spi_master_write_command(dev, 0x07); // Frame frequency
spi_master_write_command(dev, 0x07); // Define end page address
spi_master_write_command(dev, 0x00); //
spi_master_write_command(dev, 0xFF); //
spi_master_write_command(dev, OLED_CMD_ACTIVE_SCROLL); // 2F
}
if (scroll == SCROLL_LEFT) {
spi_master_write_command(dev, OLED_CMD_HORIZONTAL_LEFT); // 27
spi_master_write_command(dev, 0x00); // Dummy byte
spi_master_write_command(dev, 0x00); // Define start page address
spi_master_write_command(dev, 0x07); // Frame frequency
spi_master_write_command(dev, 0x07); // Define end page address
spi_master_write_command(dev, 0x00); //
spi_master_write_command(dev, 0xFF); //
spi_master_write_command(dev, OLED_CMD_ACTIVE_SCROLL); // 2F
}
if (scroll == SCROLL_DOWN) {
spi_master_write_command(dev, OLED_CMD_CONTINUOUS_SCROLL); // 29
spi_master_write_command(dev, 0x00); // Dummy byte
spi_master_write_command(dev, 0x00); // Define start page address
spi_master_write_command(dev, 0x07); // Frame frequency
//spi_master_write_command(dev, 0x01); // Define end page address
spi_master_write_command(dev, 0x00); // Define end page address
spi_master_write_command(dev, 0x3F); // Vertical scrolling offset
spi_master_write_command(dev, OLED_CMD_VERTICAL); // A3
spi_master_write_command(dev, 0x00);
if (dev->_height == 64)
spi_master_write_command(dev, 0x40);
if (dev->_height == 32)
spi_master_write_command(dev, 0x20);
spi_master_write_command(dev, OLED_CMD_ACTIVE_SCROLL); // 2F
}
if (scroll == SCROLL_UP) {
spi_master_write_command(dev, OLED_CMD_CONTINUOUS_SCROLL); // 29
spi_master_write_command(dev, 0x00); // Dummy byte
spi_master_write_command(dev, 0x00); // Define start page address
spi_master_write_command(dev, 0x07); // Frame frequency
//spi_master_write_command(dev, 0x01); // Define end page address
spi_master_write_command(dev, 0x00); // Define end page address
spi_master_write_command(dev, 0x01); // Vertical scrolling offset
spi_master_write_command(dev, OLED_CMD_VERTICAL); // A3
spi_master_write_command(dev, 0x00);
if (dev->_height == 64)
spi_master_write_command(dev, 0x40);
if (dev->_height == 32)
spi_master_write_command(dev, 0x20);
spi_master_write_command(dev, OLED_CMD_ACTIVE_SCROLL); // 2F
}
if (scroll == SCROLL_STOP) {
spi_master_write_command(dev, OLED_CMD_DEACTIVE_SCROLL); // 2E
}
}
| 34.270588 | 98 | 0.752947 |
30fd74dfe17a2d97f4585d2cdba3a111d6d04d8a | 35,193 | c | C | src/distances.c | monsun69/hwloc-1.11.7 | be35615dc5b148fe18a8e8a3cc2f17263c7e047e | [
"BSD-3-Clause"
] | 3 | 2019-03-23T02:57:15.000Z | 2019-03-23T02:57:22.000Z | src/distances.c | monsun69/hwloc-1.11.7 | be35615dc5b148fe18a8e8a3cc2f17263c7e047e | [
"BSD-3-Clause"
] | null | null | null | src/distances.c | monsun69/hwloc-1.11.7 | be35615dc5b148fe18a8e8a3cc2f17263c7e047e | [
"BSD-3-Clause"
] | 1 | 2020-04-03T09:33:12.000Z | 2020-04-03T09:33:12.000Z | /*
* Copyright © 2010-2017 Inria. All rights reserved.
* Copyright © 2011-2012 Université Bordeaux
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
*/
#include <private/autogen/config.h>
#include <hwloc.h>
#include <private/private.h>
#include <private/debug.h>
#include <private/misc.h>
#include <float.h>
#include <math.h>
/**************************
* Main Init/Clear/Destroy
*/
/* called during topology init */
void hwloc_distances_init(struct hwloc_topology *topology)
{
topology->first_osdist = topology->last_osdist = NULL;
}
/* called during topology destroy */
void hwloc_distances_destroy(struct hwloc_topology * topology)
{
struct hwloc_os_distances_s *osdist, *next = topology->first_osdist;
while ((osdist = next) != NULL) {
next = osdist->next;
/* remove final distance matrics AND physically-ordered ones */
free(osdist->indexes);
free(osdist->objs);
free(osdist->distances);
free(osdist);
}
topology->first_osdist = topology->last_osdist = NULL;
}
/******************************************************
* Inserting distances in the topology
* from a backend, from the environment or by the user
*/
/* insert a distance matrix in the topology.
* the caller gives us those pointers, we take care of freeing them later and so on.
*/
void hwloc_distances_set(hwloc_topology_t __hwloc_restrict topology, hwloc_obj_type_t type,
unsigned nbobjs, unsigned *indexes, hwloc_obj_t *objs, float *distances,
int force)
{
struct hwloc_os_distances_s *osdist, *next = topology->first_osdist;
/* look for existing distances for the same type */
while ((osdist = next) != NULL) {
next = osdist->next;
if (osdist->type == type) {
if (osdist->forced && !force) {
/* there is a forced distance element, ignore the new non-forced one */
free(indexes);
free(objs);
free(distances);
return;
} else if (force) {
/* we're forcing a new distance, remove the old ones */
free(osdist->indexes);
free(osdist->objs);
free(osdist->distances);
/* remove current object */
if (osdist->prev)
osdist->prev->next = next;
else
topology->first_osdist = next;
if (next)
next->prev = osdist->prev;
else
topology->last_osdist = osdist->prev;
/* free current object */
free(osdist);
}
}
}
if (!nbobjs)
/* we're just clearing, return now */
return;
assert(nbobjs >= 2);
/* create the new element */
osdist = malloc(sizeof(struct hwloc_os_distances_s));
osdist->nbobjs = nbobjs;
osdist->indexes = indexes;
osdist->objs = objs;
osdist->distances = distances;
osdist->forced = force;
osdist->type = type;
/* insert it */
osdist->next = NULL;
osdist->prev = topology->last_osdist;
if (topology->last_osdist)
topology->last_osdist->next = osdist;
else
topology->first_osdist = osdist;
topology->last_osdist = osdist;
}
/* make sure a user-given distance matrix is sane */
static int hwloc_distances__check_matrix(hwloc_topology_t __hwloc_restrict topology __hwloc_attribute_unused, hwloc_obj_type_t type __hwloc_attribute_unused,
unsigned nbobjs, unsigned *indexes, hwloc_obj_t *objs __hwloc_attribute_unused, float *distances __hwloc_attribute_unused)
{
unsigned i,j;
/* make sure we don't have the same index twice */
for(i=0; i<nbobjs; i++)
for(j=i+1; j<nbobjs; j++)
if (indexes[i] == indexes[j]) {
errno = EINVAL;
return -1;
}
return 0;
}
static void hwloc_distances__set_from_string(struct hwloc_topology *topology,
hwloc_obj_type_t type, const char *string)
{
/* the string format is: "index[0],...,index[N-1]:distance[0],...,distance[N*N-1]"
* or "index[0],...,index[N-1]:X*Y" or "index[0],...,index[N-1]:X*Y*Z"
*/
const char *tmp = string, *next;
unsigned *indexes;
float *distances;
unsigned nbobjs = 0, i, j, x, y, z;
if (!strcmp(string, "none")) {
hwloc_distances_set(topology, type, 0, NULL, NULL, NULL, 1 /* force */);
return;
}
if (sscanf(string, "%u-%u:", &i, &j) == 2) {
/* range i-j */
if (j <= i) {
fprintf(stderr, "Ignoring %s distances from environment variable, range doesn't cover at least 2 indexes\n",
hwloc_obj_type_string(type));
return;
}
nbobjs = j-i+1;
tmp = strchr(string, ':');
if (!tmp) {
fprintf(stderr, "Ignoring %s distances from environment variable, missing colon\n",
hwloc_obj_type_string(type));
return;
}
tmp++;
indexes = calloc(nbobjs, sizeof(unsigned));
distances = calloc(nbobjs*nbobjs, sizeof(float));
/* make sure the user didn't give a veeeeery large range */
if (!indexes || !distances) {
free(indexes);
free(distances);
return;
}
for(j=0; j<nbobjs; j++)
indexes[j] = j+i;
} else {
/* explicit list of indexes, count them */
while (1) {
size_t size = strspn(tmp, "0123456789");
if (!size)
/* missing index */
break;
if (tmp[size] != ',') {
/* last element */
tmp += size;
nbobjs++;
break;
}
/* another index */
tmp += size+1;
nbobjs++;
}
if (nbobjs < 2) {
fprintf(stderr, "Ignoring %s distances from environment variable, needs at least 2 indexes\n",
hwloc_obj_type_string(type));
return;
}
if (*tmp != ':') {
fprintf(stderr, "Ignoring %s distances from environment variable, missing colon\n",
hwloc_obj_type_string(type));
return;
}
indexes = calloc(nbobjs, sizeof(unsigned));
distances = calloc(nbobjs*nbobjs, sizeof(float));
tmp = string;
/* parse indexes */
for(i=0; i<nbobjs; i++) {
indexes[i] = strtoul(tmp, (char **) &next, 0);
tmp = next+1;
}
}
/* parse distances */
z=1; /* default if sscanf finds only 2 values below */
if (sscanf(tmp, "%u*%u*%u", &x, &y, &z) >= 2) {
/* generate the matrix to create x groups of y elements */
if (x*y*z != nbobjs) {
fprintf(stderr, "Ignoring %s distances from environment variable, invalid grouping (%u*%u*%u=%u instead of %u)\n",
hwloc_obj_type_string(type), x, y, z, x*y*z, nbobjs);
free(indexes);
free(distances);
return;
}
for(i=0; i<nbobjs; i++)
for(j=0; j<nbobjs; j++)
if (i==j)
distances[i*nbobjs+j] = 1;
else if (i/z == j/z)
distances[i*nbobjs+j] = 2;
else if (i/z/y == j/z/y)
distances[i*nbobjs+j] = 4;
else
distances[i*nbobjs+j] = 8;
} else {
/* parse a comma separated list of distances */
for(i=0; i<nbobjs*nbobjs; i++) {
distances[i] = (float) atof(tmp);
next = strchr(tmp, ',');
if (next) {
tmp = next+1;
} else if (i!=nbobjs*nbobjs-1) {
fprintf(stderr, "Ignoring %s distances from environment variable, not enough values (%u out of %u)\n",
hwloc_obj_type_string(type), i+1, nbobjs*nbobjs);
free(indexes);
free(distances);
return;
}
}
}
if (hwloc_distances__check_matrix(topology, type, nbobjs, indexes, NULL, distances) < 0) {
fprintf(stderr, "Ignoring invalid %s distances from environment variable\n", hwloc_obj_type_string(type));
free(indexes);
free(distances);
return;
}
hwloc_distances_set(topology, type, nbobjs, indexes, NULL, distances, 1 /* force */);
}
/* take distances in the environment, store them as is in the topology.
* we'll convert them into object later once the tree is filled
*/
void hwloc_distances_set_from_env(struct hwloc_topology *topology)
{
hwloc_obj_type_t type;
for(type = HWLOC_OBJ_SYSTEM; type < HWLOC_OBJ_TYPE_MAX; type++) {
const char *env;
char envname[64];
snprintf(envname, sizeof(envname), "HWLOC_%s_DISTANCES", hwloc_obj_type_string(type));
env = getenv(envname);
if (env) {
hwloc_localeswitch_declare;
hwloc_localeswitch_init();
hwloc_distances__set_from_string(topology, type, env);
hwloc_localeswitch_fini();
}
}
}
/* The actual set() function exported to the user
*
* take the given distance, store them as is in the topology.
* we'll convert them into object later once the tree is filled.
*/
int hwloc_topology_set_distance_matrix(hwloc_topology_t __hwloc_restrict topology, hwloc_obj_type_t type,
unsigned nbobjs, unsigned *indexes, float *distances)
{
unsigned *_indexes;
float *_distances;
if (!nbobjs && !indexes && !distances) {
hwloc_distances_set(topology, type, 0, NULL, NULL, NULL, 1 /* force */);
return 0;
}
if (nbobjs < 2 || !indexes || !distances)
return -1;
if (hwloc_distances__check_matrix(topology, type, nbobjs, indexes, NULL, distances) < 0)
return -1;
/* copy the input arrays and give them to the topology */
_indexes = malloc(nbobjs*sizeof(unsigned));
memcpy(_indexes, indexes, nbobjs*sizeof(unsigned));
_distances = malloc(nbobjs*nbobjs*sizeof(float));
memcpy(_distances, distances, nbobjs*nbobjs*sizeof(float));
hwloc_distances_set(topology, type, nbobjs, _indexes, NULL, _distances, 1 /* force */);
return 0;
}
/************************
* Restricting distances
*/
/* called when some objects have been removed because empty/ignored/cgroup/restrict,
* we must rebuild the list of objects from indexes (in hwloc_distances_finalize_os())
*/
void hwloc_distances_restrict_os(struct hwloc_topology *topology)
{
struct hwloc_os_distances_s * osdist;
for(osdist = topology->first_osdist; osdist; osdist = osdist->next) {
/* remove the objs array, we'll rebuild it from the indexes
* depending on remaining objects */
free(osdist->objs);
osdist->objs = NULL;
}
}
/* cleanup everything we created from distances so that we may rebuild them
* at the end of restrict()
*/
void hwloc_distances_restrict(struct hwloc_topology *topology, unsigned long flags)
{
if (flags & HWLOC_RESTRICT_FLAG_ADAPT_DISTANCES) {
/* some objects may have been removed, clear objects arrays so that finalize_os rebuilds them properly */
hwloc_distances_restrict_os(topology);
} else {
/* if not adapting distances, drop everything */
hwloc_distances_destroy(topology);
}
}
/**************************************************************
* Convert user/env given array of indexes into actual objects
*/
static hwloc_obj_t hwloc_find_obj_by_type_and_os_index(hwloc_obj_t root, hwloc_obj_type_t type, unsigned os_index)
{
hwloc_obj_t child;
if (root->type == type && root->os_index == os_index)
return root;
child = root->first_child;
while (child) {
hwloc_obj_t found = hwloc_find_obj_by_type_and_os_index(child, type, os_index);
if (found)
return found;
child = child->next_sibling;
}
return NULL;
}
/* convert distance indexes that were previously stored in the topology
* into actual objects if not done already.
* it's already done when distances come from backends (this function should not be called then).
* it's not done when distances come from the user.
*
* returns -1 if the matrix was invalid
*/
static int
hwloc_distances__finalize_os(struct hwloc_topology *topology, struct hwloc_os_distances_s *osdist)
{
unsigned nbobjs = osdist->nbobjs;
unsigned *indexes = osdist->indexes;
float *distances = osdist->distances;
unsigned i, j;
hwloc_obj_type_t type = osdist->type;
hwloc_obj_t *objs = calloc(nbobjs, sizeof(hwloc_obj_t));
assert(!osdist->objs);
/* traverse the topology and look for the relevant objects */
for(i=0; i<nbobjs; i++) {
hwloc_obj_t obj = hwloc_find_obj_by_type_and_os_index(topology->levels[0][0], type, indexes[i]);
if (!obj) {
/* shift the matrix */
#define OLDPOS(i,j) (distances+(i)*nbobjs+(j))
#define NEWPOS(i,j) (distances+(i)*(nbobjs-1)+(j))
if (i>0) {
/** no need to move beginning of 0th line */
for(j=0; j<i-1; j++)
/** move end of jth line + beginning of (j+1)th line */
memmove(NEWPOS(j,i), OLDPOS(j,i+1), (nbobjs-1)*sizeof(*distances));
/** move end of (i-1)th line */
memmove(NEWPOS(i-1,i), OLDPOS(i-1,i+1), (nbobjs-i-1)*sizeof(*distances));
}
if (i<nbobjs-1) {
/** move beginning of (i+1)th line */
memmove(NEWPOS(i,0), OLDPOS(i+1,0), i*sizeof(*distances));
/** move end of jth line + beginning of (j+1)th line */
for(j=i; j<nbobjs-2; j++)
memmove(NEWPOS(j,i), OLDPOS(j+1,i+1), (nbobjs-1)*sizeof(*distances));
/** move end of (nbobjs-2)th line */
memmove(NEWPOS(nbobjs-2,i), OLDPOS(nbobjs-1,i+1), (nbobjs-i-1)*sizeof(*distances));
}
/* shift the indexes array */
memmove(indexes+i, indexes+i+1, (nbobjs-i-1)*sizeof(*indexes));
/* update counters */
nbobjs--;
i--;
continue;
}
objs[i] = obj;
}
osdist->nbobjs = nbobjs;
if (!nbobjs) {
/* the whole matrix was invalid, let the caller remove this distances */
free(objs);
return -1;
}
/* setup the objs array */
osdist->objs = objs;
return 0;
}
void hwloc_distances_finalize_os(struct hwloc_topology *topology)
{
int dropall = !topology->levels[0][0]->cpuset; /* we don't support distances on multinode systems */
struct hwloc_os_distances_s *osdist, *next = topology->first_osdist;
while ((osdist = next) != NULL) {
int err;
next = osdist->next;
if (dropall)
goto drop;
/* remove final distance matrics AND physically-ordered ones */
if (osdist->objs)
/* nothing to do, switch to the next element */
continue;
err = hwloc_distances__finalize_os(topology, osdist);
if (!err)
/* convert ok, switch to the next element */
continue;
drop:
/* remove this element */
free(osdist->indexes);
free(osdist->distances);
/* remove current object */
if (osdist->prev)
osdist->prev->next = next;
else
topology->first_osdist = next;
if (next)
next->prev = osdist->prev;
else
topology->last_osdist = osdist->prev;
/* free current object */
free(osdist);
}
}
/***********************************************************
* Convert internal distances given by the backend/env/user
* into exported logical distances attached to objects
*/
static void
hwloc_distances__finalize_logical(struct hwloc_topology *topology,
unsigned nbobjs,
hwloc_obj_t *objs, float *osmatrix)
{
struct hwloc_distances_s ** tmpdistances;
unsigned i, j, li, lj, minl;
float min = FLT_MAX, max = FLT_MIN;
hwloc_obj_t root, obj;
float *matrix;
hwloc_cpuset_t cpuset, complete_cpuset;
hwloc_nodeset_t nodeset, complete_nodeset;
unsigned depth;
int idx;
/* find the root */
cpuset = hwloc_bitmap_alloc();
complete_cpuset = hwloc_bitmap_alloc();
nodeset = hwloc_bitmap_alloc();
complete_nodeset = hwloc_bitmap_alloc();
for(i=0; i<nbobjs; i++) {
hwloc_bitmap_or(cpuset, cpuset, objs[i]->cpuset);
if (objs[i]->complete_cpuset)
hwloc_bitmap_or(complete_cpuset, complete_cpuset, objs[i]->complete_cpuset);
if (objs[i]->nodeset)
hwloc_bitmap_or(nodeset, nodeset, objs[i]->nodeset);
if (objs[i]->complete_nodeset)
hwloc_bitmap_or(complete_nodeset, complete_nodeset, objs[i]->complete_nodeset);
}
/* find the object covering cpuset, we'll take care of the nodeset later */
root = hwloc_get_obj_covering_cpuset(topology, cpuset);
/* walk up to find a parent that also covers the nodeset */
while (root &&
(!hwloc_bitmap_isincluded(nodeset, root->nodeset)
|| !hwloc_bitmap_isincluded(complete_nodeset, root->complete_nodeset)
|| !hwloc_bitmap_isincluded(complete_cpuset, root->complete_cpuset)))
root = root->parent;
if (!root) {
/* should not happen unless cpuset is empty.
* cpuset may be empty if some objects got removed by KEEP_STRUCTURE, etc
* or if all objects are CPU-less.
*/
if (!hwloc_hide_errors() && !hwloc_bitmap_iszero(cpuset)) {
char *a, *b;
hwloc_bitmap_asprintf(&a, cpuset);
hwloc_bitmap_asprintf(&b, nodeset);
fprintf(stderr, "****************************************************************************\n");
fprintf(stderr, "* hwloc %s has encountered an error when adding a distance matrix to the topology.\n", HWLOC_VERSION);
fprintf(stderr, "*\n");
fprintf(stderr, "* hwloc_distances__finalize_logical() could not find any object covering\n");
fprintf(stderr, "* cpuset %s and nodeset %s\n", a, b);
fprintf(stderr, "*\n");
fprintf(stderr, "* Please report this error message to the hwloc user's mailing list,\n");
#ifdef HWLOC_LINUX_SYS
fprintf(stderr, "* along with the files generated by the hwloc-gather-topology script.\n");
#else
fprintf(stderr, "* along with any relevant topology information from your platform.\n");
#endif
fprintf(stderr, "****************************************************************************\n");
free(a);
free(b);
}
hwloc_bitmap_free(cpuset);
hwloc_bitmap_free(complete_cpuset);
hwloc_bitmap_free(nodeset);
hwloc_bitmap_free(complete_nodeset);
return;
}
/* don't attach to Misc objects */
while (root->type == HWLOC_OBJ_MISC)
root = root->parent;
/* ideally, root has the exact cpuset and nodeset.
* but ignoring or other things that remove objects may cause the object array to reduce */
assert(hwloc_bitmap_isincluded(cpuset, root->cpuset));
assert(hwloc_bitmap_isincluded(complete_cpuset, root->complete_cpuset));
assert(hwloc_bitmap_isincluded(nodeset, root->nodeset));
assert(hwloc_bitmap_isincluded(complete_nodeset, root->complete_nodeset));
hwloc_bitmap_free(cpuset);
hwloc_bitmap_free(complete_cpuset);
hwloc_bitmap_free(nodeset);
hwloc_bitmap_free(complete_nodeset);
depth = objs[0]->depth; /* this assume that we have distances between objects of the same level */
if (root->depth >= depth) {
/* strange topology led us to find invalid relative depth, ignore */
return;
}
/* count objects at that depth that are below root.
* we can't use hwloc_get_nbobjs_inside_cpuset_by_depth() because it ignore CPU-less objects.
*/
i = 0;
obj = NULL;
while ((obj = hwloc_get_next_obj_by_depth(topology, depth, obj)) != NULL) {
hwloc_obj_t myparent = obj->parent;
while (myparent->depth > root->depth)
myparent = myparent->parent;
if (myparent == root)
i++;
}
if (i != nbobjs)
/* the root does not cover the right number of objects, maybe we failed to insert a root (bad intersect or so). */
return;
/* get the logical index offset, it's the min of all logical indexes */
minl = UINT_MAX;
for(i=0; i<nbobjs; i++)
if (minl > objs[i]->logical_index)
minl = objs[i]->logical_index;
/* compute/check min/max values */
for(i=0; i<nbobjs; i++)
for(j=0; j<nbobjs; j++) {
float val = osmatrix[i*nbobjs+j];
if (val < min)
min = val;
if (val > max)
max = val;
}
if (!min) {
/* Linux up to 2.6.36 reports ACPI SLIT distances, which should be memory latencies.
* Except of SGI IP27 (SGI Origin 200/2000 with MIPS processors) where the distances
* are the number of hops between routers.
*/
hwloc_debug("%s", "minimal distance is 0, matrix does not seem to contain latencies, ignoring\n");
return;
}
/* store the normalized latency matrix in the root object */
tmpdistances = realloc(root->distances, (root->distances_count+1) * sizeof(struct hwloc_distances_s *));
if (!tmpdistances)
return; /* Failed to allocate, ignore this distance matrix */
root->distances = tmpdistances;
idx = root->distances_count++;
root->distances[idx] = malloc(sizeof(struct hwloc_distances_s));
root->distances[idx]->relative_depth = depth - root->depth;
root->distances[idx]->nbobjs = nbobjs;
root->distances[idx]->latency = matrix = malloc(nbobjs*nbobjs*sizeof(float));
root->distances[idx]->latency_base = (float) min;
#define NORMALIZE_LATENCY(d) ((d)/(min))
root->distances[idx]->latency_max = NORMALIZE_LATENCY(max);
for(i=0; i<nbobjs; i++) {
li = objs[i]->logical_index - minl;
matrix[li*nbobjs+li] = NORMALIZE_LATENCY(osmatrix[i*nbobjs+i]);
for(j=i+1; j<nbobjs; j++) {
lj = objs[j]->logical_index - minl;
matrix[li*nbobjs+lj] = NORMALIZE_LATENCY(osmatrix[i*nbobjs+j]);
matrix[lj*nbobjs+li] = NORMALIZE_LATENCY(osmatrix[j*nbobjs+i]);
}
}
}
/* convert internal distances into logically-ordered distances
* that can be exposed in the API
*/
void
hwloc_distances_finalize_logical(struct hwloc_topology *topology)
{
unsigned nbobjs;
int depth;
struct hwloc_os_distances_s * osdist;
for(osdist = topology->first_osdist; osdist; osdist = osdist->next) {
nbobjs = osdist->nbobjs;
if (!nbobjs)
continue;
depth = hwloc_get_type_depth(topology, osdist->type);
if (depth == HWLOC_TYPE_DEPTH_UNKNOWN || depth == HWLOC_TYPE_DEPTH_MULTIPLE)
continue;
if (osdist->objs) {
assert(osdist->distances);
hwloc_distances__finalize_logical(topology, nbobjs,
osdist->objs,
osdist->distances);
}
}
}
/***************************************************
* Destroying logical distances attached to objects
*/
/* destroy an object distances structure */
void
hwloc_clear_object_distances_one(struct hwloc_distances_s * distances)
{
free(distances->latency);
free(distances);
}
void
hwloc_clear_object_distances(hwloc_obj_t obj)
{
unsigned i;
for (i=0; i<obj->distances_count; i++)
hwloc_clear_object_distances_one(obj->distances[i]);
free(obj->distances);
obj->distances = NULL;
obj->distances_count = 0;
}
/******************************************
* Grouping objects according to distances
*/
static void hwloc_report_user_distance_error(const char *msg, int line)
{
static int reported = 0;
if (!reported && !hwloc_hide_errors()) {
fprintf(stderr, "****************************************************************************\n");
fprintf(stderr, "* hwloc %s has encountered what looks like an error from user-given distances.\n", HWLOC_VERSION);
fprintf(stderr, "*\n");
fprintf(stderr, "* %s\n", msg);
fprintf(stderr, "* Error occurred in topology.c line %d\n", line);
fprintf(stderr, "*\n");
fprintf(stderr, "* Please make sure that distances given through the interface or environment\n");
fprintf(stderr, "* variables do not contradict any other topology information.\n");
fprintf(stderr, "****************************************************************************\n");
reported = 1;
}
}
static int hwloc_compare_distances(float a, float b, float accuracy)
{
if (accuracy != 0.0 && fabsf(a-b) < a * accuracy)
return 0;
return a < b ? -1 : a == b ? 0 : 1;
}
/*
* Place objects in groups if they are in a transitive graph of minimal distances.
* Return how many groups were created, or 0 if some incomplete distance graphs were found.
*/
static unsigned
hwloc__find_groups_by_min_distance(unsigned nbobjs,
float *_distances,
float accuracy,
unsigned *groupids,
int verbose)
{
float min_distance = FLT_MAX;
unsigned groupid = 1;
unsigned i,j,k;
unsigned skipped = 0;
#define DISTANCE(i, j) _distances[(i) * nbobjs + (j)]
memset(groupids, 0, nbobjs*sizeof(*groupids));
/* find the minimal distance */
for(i=0; i<nbobjs; i++)
for(j=0; j<nbobjs; j++) /* check the entire matrix, it may not be perfectly symmetric depending on the accuracy */
if (i != j && DISTANCE(i, j) < min_distance) /* no accuracy here, we want the real minimal */
min_distance = DISTANCE(i, j);
hwloc_debug("found minimal distance %f between objects\n", min_distance);
if (min_distance == FLT_MAX)
return 0;
/* build groups of objects connected with this distance */
for(i=0; i<nbobjs; i++) {
unsigned size;
int firstfound;
/* if already grouped, skip */
if (groupids[i])
continue;
/* start a new group */
groupids[i] = groupid;
size = 1;
firstfound = i;
while (firstfound != -1) {
/* we added new objects to the group, the first one was firstfound.
* rescan all connections from these new objects (starting at first found) to any other objects,
* so as to find new objects minimally-connected by transivity.
*/
int newfirstfound = -1;
for(j=firstfound; j<nbobjs; j++)
if (groupids[j] == groupid)
for(k=0; k<nbobjs; k++)
if (!groupids[k] && !hwloc_compare_distances(DISTANCE(j, k), min_distance, accuracy)) {
groupids[k] = groupid;
size++;
if (newfirstfound == -1)
newfirstfound = k;
if (i == j)
hwloc_debug("object %u is minimally connected to %u\n", k, i);
else
hwloc_debug("object %u is minimally connected to %u through %u\n", k, i, j);
}
firstfound = newfirstfound;
}
if (size == 1) {
/* cancel this useless group, ignore this object and try from the next one */
groupids[i] = 0;
skipped++;
continue;
}
/* valid this group */
groupid++;
if (verbose)
fprintf(stderr, "Found transitive graph with %u objects with minimal distance %f accuracy %f\n",
size, min_distance, accuracy);
}
if (groupid == 2 && !skipped)
/* we created a single group containing all objects, ignore it */
return 0;
/* return the last id, since it's also the number of used group ids */
return groupid-1;
}
/* check that the matrix is ok */
static int
hwloc__check_grouping_matrix(unsigned nbobjs, float *_distances, float accuracy, int verbose)
{
unsigned i,j;
for(i=0; i<nbobjs; i++) {
for(j=i+1; j<nbobjs; j++) {
/* should be symmetric */
if (hwloc_compare_distances(DISTANCE(i, j), DISTANCE(j, i), accuracy)) {
if (verbose)
fprintf(stderr, "Distance matrix asymmetric ([%u,%u]=%f != [%u,%u]=%f), aborting\n",
i, j, DISTANCE(i, j), j, i, DISTANCE(j, i));
return -1;
}
/* diagonal is smaller than everything else */
if (hwloc_compare_distances(DISTANCE(i, j), DISTANCE(i, i), accuracy) <= 0) {
if (verbose)
fprintf(stderr, "Distance to self not strictly minimal ([%u,%u]=%f <= [%u,%u]=%f), aborting\n",
i, j, DISTANCE(i, j), i, i, DISTANCE(i, i));
return -1;
}
}
}
return 0;
}
/*
* Look at object physical distances to group them.
*/
static void
hwloc__groups_by_distances(struct hwloc_topology *topology,
unsigned nbobjs,
struct hwloc_obj **objs,
float *_distances,
unsigned nbaccuracies, float *accuracies,
int fromuser,
int needcheck,
int verbose)
{
unsigned *groupids = NULL;
unsigned nbgroups = 0;
unsigned i,j;
if (nbobjs <= 2) {
return;
}
groupids = malloc(sizeof(unsigned) * nbobjs);
if (NULL == groupids) {
return;
}
for(i=0; i<nbaccuracies; i++) {
if (verbose)
fprintf(stderr, "Trying to group %u %s objects according to physical distances with accuracy %f\n",
nbobjs, hwloc_obj_type_string(objs[0]->type), accuracies[i]);
if (needcheck && hwloc__check_grouping_matrix(nbobjs, _distances, accuracies[i], verbose) < 0)
continue;
nbgroups = hwloc__find_groups_by_min_distance(nbobjs, _distances, accuracies[i], groupids, verbose);
if (nbgroups)
break;
}
if (!nbgroups)
goto outter_free;
/* For convenience, put these declarations inside a block. It's a
crying shame we can't use C99 syntax here, and have to do a bunch
of mallocs. :-( */
{
hwloc_obj_t *groupobjs = NULL;
unsigned *groupsizes = NULL;
float *groupdistances = NULL;
unsigned failed = 0;
groupobjs = malloc(sizeof(hwloc_obj_t) * nbgroups);
groupsizes = malloc(sizeof(unsigned) * nbgroups);
groupdistances = malloc(sizeof(float) * nbgroups * nbgroups);
if (NULL == groupobjs || NULL == groupsizes || NULL == groupdistances) {
goto inner_free;
}
/* create new Group objects and record their size */
memset(&(groupsizes[0]), 0, sizeof(groupsizes[0]) * nbgroups);
for(i=0; i<nbgroups; i++) {
/* create the Group object */
hwloc_obj_t group_obj, res_obj;
group_obj = hwloc_alloc_setup_object(HWLOC_OBJ_GROUP, -1);
group_obj->cpuset = hwloc_bitmap_alloc();
group_obj->attr->group.depth = topology->next_group_depth;
for (j=0; j<nbobjs; j++)
if (groupids[j] == i+1) {
/* assemble the group cpuset */
hwloc_bitmap_or(group_obj->cpuset, group_obj->cpuset, objs[j]->cpuset);
if (objs[i]->complete_cpuset) {
if (!group_obj->complete_cpuset)
group_obj->complete_cpuset = hwloc_bitmap_alloc();
hwloc_bitmap_or(group_obj->complete_cpuset, group_obj->complete_cpuset, objs[j]->complete_cpuset);
}
/* if one obj has a nodeset, assemble a group nodeset */
if (objs[j]->nodeset) {
if (!group_obj->nodeset)
group_obj->nodeset = hwloc_bitmap_alloc();
hwloc_bitmap_or(group_obj->nodeset, group_obj->nodeset, objs[j]->nodeset);
}
if (objs[i]->complete_nodeset) {
if (!group_obj->complete_nodeset)
group_obj->complete_nodeset = hwloc_bitmap_alloc();
hwloc_bitmap_or(group_obj->complete_nodeset, group_obj->complete_nodeset, objs[j]->complete_nodeset);
}
groupsizes[i]++;
}
hwloc_debug_1arg_bitmap("adding Group object with %u objects and cpuset %s\n",
groupsizes[i], group_obj->cpuset);
res_obj = hwloc__insert_object_by_cpuset(topology, group_obj,
fromuser ? hwloc_report_user_distance_error : hwloc_report_os_error);
/* res_obj may be NULL on failure to insert. */
if (!res_obj)
failed++;
/* or it may be different from groupobjs if we got groups from XML import before grouping */
groupobjs[i] = res_obj;
}
if (failed)
/* don't try to group above if we got a NULL group here, just keep this incomplete level */
goto inner_free;
/* factorize distances */
memset(&(groupdistances[0]), 0, sizeof(groupdistances[0]) * nbgroups * nbgroups);
#undef DISTANCE
#define DISTANCE(i, j) _distances[(i) * nbobjs + (j)]
#define GROUP_DISTANCE(i, j) groupdistances[(i) * nbgroups + (j)]
for(i=0; i<nbobjs; i++)
if (groupids[i])
for(j=0; j<nbobjs; j++)
if (groupids[j])
GROUP_DISTANCE(groupids[i]-1, groupids[j]-1) += DISTANCE(i, j);
for(i=0; i<nbgroups; i++)
for(j=0; j<nbgroups; j++) {
unsigned groupsize = groupsizes[i]*groupsizes[j];
float groupsizef = (float) groupsize;
GROUP_DISTANCE(i, j) /= groupsizef;
}
#ifdef HWLOC_DEBUG
hwloc_debug("%s", "generated new distance matrix between groups:\n");
hwloc_debug("%s", " index");
for(j=0; j<nbgroups; j++)
hwloc_debug(" % 5d", (int) j); /* print index because os_index is -1 for Groups */
hwloc_debug("%s", "\n");
for(i=0; i<nbgroups; i++) {
hwloc_debug(" % 5d", (int) i);
for(j=0; j<nbgroups; j++)
hwloc_debug(" %2.3f", GROUP_DISTANCE(i, j));
hwloc_debug("%s", "\n");
}
#endif
topology->next_group_depth++;
hwloc__groups_by_distances(topology, nbgroups, groupobjs, (float*) groupdistances, nbaccuracies, accuracies, fromuser, 0 /* no need to check generated matrix */, verbose);
inner_free:
/* Safely free everything */
if (NULL != groupobjs) {
free(groupobjs);
}
if (NULL != groupsizes) {
free(groupsizes);
}
if (NULL != groupdistances) {
free(groupdistances);
}
}
outter_free:
if (NULL != groupids) {
free(groupids);
}
}
void
hwloc_group_by_distances(struct hwloc_topology *topology)
{
unsigned nbobjs;
struct hwloc_os_distances_s * osdist;
const char *env;
float accuracies[5] = { 0.0f, 0.01f, 0.02f, 0.05f, 0.1f };
unsigned nbaccuracies = 5;
hwloc_obj_t group_obj;
int verbose = 0;
unsigned i;
hwloc_localeswitch_declare;
#ifdef HWLOC_DEBUG
unsigned j;
#endif
env = getenv("HWLOC_GROUPING");
if (env && !atoi(env))
return;
/* backward compat with v1.2 */
if (getenv("HWLOC_IGNORE_DISTANCES"))
return;
hwloc_localeswitch_init();
env = getenv("HWLOC_GROUPING_ACCURACY");
if (!env) {
/* only use 0.0 */
nbaccuracies = 1;
} else if (strcmp(env, "try")) {
/* use the given value */
nbaccuracies = 1;
accuracies[0] = (float) atof(env);
} /* otherwise try all values */
hwloc_localeswitch_fini();
#ifdef HWLOC_DEBUG
verbose = 1;
#else
env = getenv("HWLOC_GROUPING_VERBOSE");
if (env)
verbose = atoi(env);
#endif
for(osdist = topology->first_osdist; osdist; osdist = osdist->next) {
nbobjs = osdist->nbobjs;
if (!nbobjs)
continue;
if (osdist->objs) {
/* if we have objs, we must have distances as well,
* thanks to hwloc_convert_distances_indexes_into_objects()
*/
assert(osdist->distances);
#ifdef HWLOC_DEBUG
hwloc_debug("%s", "trying to group objects using distance matrix:\n");
hwloc_debug("%s", " index");
for(j=0; j<nbobjs; j++)
hwloc_debug(" % 5d", (int) osdist->objs[j]->os_index);
hwloc_debug("%s", "\n");
for(i=0; i<nbobjs; i++) {
hwloc_debug(" % 5d", (int) osdist->objs[i]->os_index);
for(j=0; j<nbobjs; j++)
hwloc_debug(" %2.3f", osdist->distances[i*nbobjs + j]);
hwloc_debug("%s", "\n");
}
#endif
hwloc__groups_by_distances(topology, nbobjs,
osdist->objs,
osdist->distances,
nbaccuracies, accuracies,
osdist->indexes != NULL,
1 /* check the first matrice */,
verbose);
/* add a final group object covering everybody so that the distance matrix can be stored somewhere.
* this group will be merged into a regular object if the matrix isn't strangely incomplete
*/
group_obj = hwloc_alloc_setup_object(HWLOC_OBJ_GROUP, -1);
group_obj->attr->group.depth = (unsigned) -1;
group_obj->cpuset = hwloc_bitmap_alloc();
for(i=0; i<nbobjs; i++) {
/* assemble the group cpuset */
hwloc_bitmap_or(group_obj->cpuset, group_obj->cpuset, osdist->objs[i]->cpuset);
if (osdist->objs[i]->complete_cpuset) {
if (!group_obj->complete_cpuset)
group_obj->complete_cpuset = hwloc_bitmap_alloc();
hwloc_bitmap_or(group_obj->complete_cpuset, group_obj->complete_cpuset, osdist->objs[i]->complete_cpuset);
}
/* if one obj has a nodeset, assemble a group nodeset */
if (osdist->objs[i]->nodeset) {
if (!group_obj->nodeset)
group_obj->nodeset = hwloc_bitmap_alloc();
hwloc_bitmap_or(group_obj->nodeset, group_obj->nodeset, osdist->objs[i]->nodeset);
}
if (osdist->objs[i]->complete_nodeset) {
if (!group_obj->complete_nodeset)
group_obj->complete_nodeset = hwloc_bitmap_alloc();
hwloc_bitmap_or(group_obj->complete_nodeset, group_obj->complete_nodeset, osdist->objs[i]->complete_nodeset);
}
}
hwloc_debug_1arg_bitmap("adding Group object (as root of distance matrix with %u objects) with cpuset %s\n",
nbobjs, group_obj->cpuset);
hwloc__insert_object_by_cpuset(topology, group_obj,
osdist->indexes != NULL ? hwloc_report_user_distance_error : hwloc_report_os_error);
}
}
}
| 32.465867 | 177 | 0.6451 |
c84eac34a46c3cc0705998451888e654ab1d0781 | 26,663 | h | C | udf.h | Randrianasulu/udfclient-termux | be4a1882f0ddc9392a0a760c8093822d9a3af92c | [
"ClArtistic"
] | 1 | 2021-01-22T13:19:22.000Z | 2021-01-22T13:19:22.000Z | udf.h | kan19810606/udfclient | 3bff552dae05664924b1d5afe1adae12c46d4cad | [
"ClArtistic"
] | null | null | null | udf.h | kan19810606/udfclient | 3bff552dae05664924b1d5afe1adae12c46d4cad | [
"ClArtistic"
] | null | null | null | /* $NetBSD$ */
/*
* File "udf.h" is part of the UDFclient toolkit.
* File $Id: udf.h,v 1.149 2015/08/05 18:26:30 reinoud Exp $ $Name: $
*
* Copyright (c) 2003, 2004, 2005, 2006, 2011
* Reinoud Zandijk <reinoud@netbsd.org>
* All rights reserved.
*
* The UDFclient toolkit is distributed under the Clarified Artistic Licence.
* A copy of the licence is included in the distribution as
* `LICENCE.clearified.artistic' and a copy of the licence can also be
* requested at the GNU foundantion's website.
*
* Visit the UDFclient toolkit homepage http://www.13thmonkey.org/udftoolkit/
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef _UDF_H_
#define _UDF_H_
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <inttypes.h>
#include "dirhash.h"
#ifdef NO_INT_FMTIO
/* assume 32 bits :-/ */
#ifndef PRIu32
# define PRIu32 "u"
# define PRIx32 "x"
# define PRIu64 "lld"
# define PRIx64 "llx"
#endif
#endif
/* exported flags */
extern int udf_verbose;
#define UDF_MNT_RDONLY 1
#define UDF_MNT_FORCE 2
#define UDF_MNT_BSWAP 4
#define UDF_VERBLEV_NONE 0
#define UDF_VERBLEV_ACTIONS 1
#define UDF_VERBLEV_TABLES 2
#define UDF_VERBLEV_MAX 3
/* constants to identify what kind of identifier we are dealing with */
#define UDF_REGID_DOMAIN 1
#define UDF_REGID_UDF 2
#define UDF_REGID_IMPLEMENTATION 3
#define UDF_REGID_APPLICATION 4
#define UDF_REGID_NAME 99 /* 99? */
/* RW content hint for allocation and other purposes */
#define UDF_C_DSCR 0
#define UDF_C_USERDATA 1
#define UDF_C_FIDS 2
#define UDF_C_NODE 3
/* Configuration */
#define UDF_MINFREE_LOGVOL (128*1024) /* max sector is 64kb, give 2 (sorry) slack; use with care */
#define UDF_LOOKUP_READAHEAD 64 /* rewrite lookahead; set lookahead 0 to disable */
/* misc. configuration; don't change unless you know what you're doing */
#define UDF_READWRITE_LINE_LENGTH 32 /* DONT change this! 32 sectors for CD-RW/DVD-RW fixed packets */
#define UDF_READWRITE_ALL_PRESENT 0xffffffff
#define UDF_INODE_HASHBITS 10
#define UDF_INODE_HASHSIZE (1<<UDF_INODE_HASHBITS)
#define UDF_INODE_HASHMASK (UDF_INODE_HASHSIZE - 1)
#define UDF_BUFCACHE_HASHBITS 13
#define UDF_BUFCACHE_HASHSIZE (1<<UDF_BUFCACHE_HASHBITS)
#define UDF_BUFCACHE_HASHMASK (UDF_BUFCACHE_HASHSIZE - 1)
#define UDF_BUFCACHE_IDLE_SECS 15 /* chosen... but preferably before the device spins down (!) */
#define UDF_LRU_METADATA_MIN (100 * UDF_READWRITE_LINE_LENGTH)
#define UDF_LRU_METADATA_MAX (150 * UDF_READWRITE_LINE_LENGTH)
#define UDF_LRU_DATA_MIN (100 * UDF_READWRITE_LINE_LENGTH)
#define UDF_LRU_DATA_MAX (300 * UDF_READWRITE_LINE_LENGTH)
/* end of Configuration */
#if 1
# define UDF_VERBOSE(op) if (udf_verbose) { op; }
# define UDF_VERBOSE_LEVEL(level, op) if (udf_verbose >= (level)) { op; }
# define UDF_VERBOSE_TABLES(op) UDF_VERBOSE_LEVEL(UDF_VERBLEV_TABLES, op)
# define UDF_VERBOSE_MAX(op) UDF_VERBOSE_LEVEL(UDF_VERBLEV_MAX, op)
#else
# define UDF_VERBOSE(op)
# define UDF_VERBOSE_LEVEL(level, op)
# define UDF_VERBOSE_TABLES(op)
# define UDF_VERBOSE_MAX(op)
#endif
#define UDF_MUTEX(name) struct { \
pthread_mutex_t mutex;\
int locked;\
char *status;\
char *file;\
int line;\
} name
#define UDF_MUTEX_INIT(name) { \
pthread_mutex_init(&(name)->mutex, 0); \
(name)->locked = 0; \
(name)->status = "initialised as " #name;\
(name)->file = __FILE__;\
(name)->line = __LINE__;\
}
#define UDF_MUTEX_LOCK(name) { \
if (0 && (name)->locked) printf("Waiting for lock " #name " at line %d of file %s marked %s in %s at line %d\n", __LINE__, __FILE__, (name)->status, (name)->file, (name)->line);\
pthread_mutex_lock(&(name)->mutex);\
(name)->locked = 1; \
(name)->status = "locked as " #name;\
(name)->file = __FILE__;\
(name)->line = __LINE__;\
}
#define UDF_MUTEX_TRYLOCK(name) { \
if (0) printf("Trying lock " #name " at line %d of file %s marked %s in %s at line %d\n", __LINE__, __FILE__, (name)->status, (name)->file, (name)->line);\
if (pthread_mutex_trylock(&(name)->mutex) != EBUSY) {\
(name)->locked = 1;\
(name)->status = "locked as " #name;\
(name)->file = __FILE__;\
(name)->line = __LINE__;\
};\
}
#define UDF_MUTEX_UNLOCK(name) { \
if (0 && !(name)->locked) printf("Unlocking lock " #name " at line %d of file %s marked %s in %s at line %d\n", __LINE__, __FILE__, (name)->status, (name)->file, (name)->line);\
(name)->locked = 0; \
(name)->status = "unlocked as " #name;\
(name)->file = __FILE__;\
(name)->line = __LINE__;\
pthread_mutex_unlock(&(name)->mutex);\
}
/* Predefines */
struct udf_node;
struct udf_mountpoint;
#include "osta.h"
#include "ecma167-udf.h"
#include "queue.h"
#include "udf_discop.h"
#include "udf_unix.h"
#include "uio.h"
#include <pthread.h>
/*---------------------------------------------------------------------*/
/*
* Provides :: write action -> signal written OK or signal write error
* NOTE: not used anymore but kept for convenience when write error resolution
* is build.
*/
struct udf_wrcallback;
typedef void (udf_wrcallback_func)(int reason, struct udf_wrcallback *wrcallback, int error, uint8_t *sectordata);
struct udf_wrcallback {
udf_wrcallback_func *function;
struct udf_buf *udf_buf; /* associated buffer */
struct udf_node *udf_node; /* associated vnode */
uint32_t flags; /* some reserved flags but other bits are OK */
};
#define UDF_WRCALLBACK_REASON_PENDING 0
#define UDF_WRCALLBACK_REASON_ANULATE 1
#define UDF_WRCALLBACK_REASON_WRITTEN 2
#define UDF_WRCALLBACK_FLAG_DESCRIPTOR (1<<0)
#define UDF_WRCALLBACK_FLAG_BUFFER (1<<1)
/*
* Provides :: ``allocentry'' an ordered list of allocation extents
*
*/
struct udf_allocentry {
uint32_t len;
uint32_t lb_num;
uint16_t vpart_num;
uint8_t flags;
TAILQ_ENTRY(udf_allocentry) next_alloc;
};
#define UDF_SPACE_ALLOCATED 0
#define UDF_SPACE_FREED 1
#define UDF_SPACE_ALLOCATED_BUT_NOT_USED 1
#define UDF_SPACE_FREE 2
#define UDF_SPACE_REDIRECT 3
TAILQ_HEAD(udf_alloc_entries, udf_allocentry);
/*
* Provides :: ``inode'' or rather filing system dependent v_data node linked under vnode structure
*
*/
struct udf_node {
struct udf_mountpoint *mountpoint; /* foreign; provides logvol and fileset */
struct udf_log_vol *udf_log_vol; /* foreign; backup if its not associated to mountpoint */
int dirty; /* flags if (ext)fentry needs to be synced (safeguard) */
int hold; /* node is on hold i.e. don't recycle nor its buffers */
ino_t hashkey; /* for hashing to lookup inode by vpart & lbnum */
struct stat stat; /* holds unix file attributes/filestats */
struct udf_alloc_entries dscr_allocs; /* where my complete descriptor space is located */
uint8_t udf_filetype; /* filetype of this node; raw, block, char, softlink... */
uint8_t udf_filechar; /* udf file characteristics (vis, meta, ... */
uint16_t serial_num; /* serial number of this descriptor on disc */
uint16_t file_version_num; /* file version number of this descriptor on disc */
uint16_t udf_icbtag_flags; /* serial, setuid, setguid, stickybit etc */
uint16_t link_cnt; /* how many FID's are linked to this (ext)fentry */
uint64_t unique_id; /* unique file ID */
/* extended attributes and subfiles */
struct udf_alloc_entry *extattrfile_icb; /* associated extended attribute file */
struct udf_alloc_entry *streamdir_icb; /* associated streamdir */
/* internal in-node storage of extended attributes copy. */
uint8_t *extended_attr;
uint32_t extended_attr_len;
/* internal in-node storage of data copy */
uint8_t *intern_data; /* descriptor internal data */
uint32_t intern_len; /* length of descriptor internal data */
uint32_t intern_free; /* free space amount in the descriptor besides extattr. */
/* extents of discspace that make up this file/directory */
uint32_t addr_type; /* storage type of allocation descriptors */
uint32_t icb_len; /* length of an icb descriptor */
UDF_MUTEX(alloc_mutex);
struct udf_alloc_entries alloc_entries;
/* all associated vn_bufs for this node */
UDF_MUTEX(buf_mutex);
struct udf_buf_queue vn_bufs;
uint32_t v_numoutput;
/* dir hasing */
struct dirhash *dir_hash;
/* lists */
TAILQ_ENTRY(udf_node) next_dirty; /* next in dirty node list */
LIST_ENTRY(udf_node) next_node; /* next in hash node list */
};
TAILQ_HEAD(udf_node_list, udf_node);
/*---------------------------------------------------------------------*/
/*
* Provides :: mountpoint -> fileset descriptor and logical volume
*
*/
struct udf_mountpoint {
char *mount_name; /* identifier */
struct udf_log_vol *udf_log_vol; /* foreign */
struct fileset_desc *fileset_desc; /* fileset belonging to this mountpoint */
struct udf_node *rootdir_node;
struct udf_node *streamdir_node;
int writable; /* flags if its a writable fileset */
SLIST_ENTRY(udf_mountpoint) all_next; /* for overall mountpoint list */
SLIST_ENTRY(udf_mountpoint) logvol_next; /* for list of mountpoints in a logvol */
};
/*
* Provides :: logvol_partition -> volumeset physical partition
*/
struct udf_part_mapping {
uint32_t udf_part_mapping_type;
uint32_t vol_seq_num;
uint32_t udf_virt_part_num;
uint32_t udf_phys_part_num;
union udf_pmap *udf_pmap; /* foreign */
int data_writable; /* flags if its suited for data */
int metadata_writable; /* flags if its for meta-data */
/* supporting tables */
struct udf_sparing_table *sparing_table;
/* virtual space */
struct udf_node *vat_udf_node;
struct udf_vat *vat;
uint8_t *vat_translation;
uint32_t vat_entries;
uint32_t vat_length;
/* needs to be updated; metadata partition disabled for now */
struct udf_node *meta_file;
struct udf_node *meta_mirror_file;
struct udf_node *meta_bitmap_file;
SLIST_ENTRY(udf_part_mapping) next_mapping; /* for list of partition mappings */
};
#define UDF_PART_MAPPING_ERROR 0
#define UDF_PART_MAPPING_PHYSICAL 1
#define UDF_PART_MAPPING_VIRTUAL 2
#define UDF_PART_MAPPING_SPARABLE 3
#define UDF_PART_MAPPING_META 4
#define UDF_PART_MAPPING_PSEUDO_RW 5
/*
* Provides :: log_vol -> ...
* :: MOUNTPOINTS :)
*/
struct udf_log_vol {
int broken;
/* primary volume this logical volume is recorded on */
struct udf_pri_vol *primary; /* foreign */
/* logical volume info */
struct logvol_desc *log_vol;
uint32_t lb_size; /* constant over logvol in Ecma 167 */
uint32_t sector_size; /* constant over logvol in Ecma 167 */
/* logical volume integrity/VAT information */
uint32_t logvol_state; /* maintained */
uint16_t integrity_serial;
uint32_t min_udf_readver;
uint32_t min_udf_writever;
uint32_t max_udf_writever;
uint32_t num_files; /* maintained */
uint32_t num_directories; /* maintained */
uint64_t next_unique_id; /* maintained */
int writable; /* flags if its writable */
/* dirty nodes administration */
UDF_MUTEX(dirty_nodes_mutex);
struct udf_node_list dirty_nodes;
/* hash table to lookup ino_t -> udf_node */
LIST_HEAD(inodes, udf_node) udf_nodes[UDF_INODE_HASHSIZE];
/* estimated free space summation; from logvol integrity */
uint64_t total_space;
uint64_t free_space;
uint64_t await_alloc_space;
/* consisting of */
uint32_t data_vpart, metadata_vpart;
uint32_t num_mountpoints; /* display only */
SLIST_HEAD(mountpoints_list, udf_mountpoint) mountpoints; /* list of mountables in logvol */
uint32_t num_part_mappings; /* display only */
SLIST_HEAD(part_mappings_list, udf_part_mapping) part_mappings; /* list of partition mappings */
/* next in list */
SLIST_ENTRY(udf_log_vol) next_logvol; /* for list of logical volumes in a primary volume */
};
/*
* Provides :: pri_vol -> [log_vol], [part],[ ...]
* :: { volumeset -> [pri_vols] }
*/
struct udf_pri_vol {
struct pri_vol_desc *pri_vol;
struct udf_session *udf_session;
struct impvol_desc *implemation; /* most likely reduntant */
struct udf_volumeset *volumeset; /* foreign ; nesissary? */
struct unalloc_sp_desc *unallocated;
/* associated logical volumes */
SLIST_HEAD(logvols, udf_log_vol) log_vols; /* list of associated logical volumes */
STAILQ_ENTRY(udf_pri_vol) next_primary; /* for primary list in volumeset */
};
/*
* Provides :: partion -> [partition info, session]
*/
struct udf_partition {
struct part_desc *partition;
struct udf_session *udf_session; /* foreign */
uint64_t part_offset;
uint64_t part_length;
UDF_MUTEX(partition_space_mutex); /* MUTEX for unalloc and freed space */
uint64_t free_unalloc_space;
struct udf_alloc_entries unalloc_space_queue; /* authorative */
struct space_bitmap_desc *unalloc_space_bitmap; /* placeholder! does NOT have to be up-to-date */
uint64_t free_freed_space;
struct udf_alloc_entries freed_space_queue; /* authorative */
struct space_bitmap_desc *freed_space_bitmap; /* placeholder! does NOT have to be up-to-date */
SLIST_ENTRY(udf_partition) next_partition; /* for partition list in volumeset */
};
/*
* Provides :: volumeset -> [pri_vol]
* :: [volumeset]
*/
struct udf_volumeset {
int obsolete;
uint32_t max_partnum;
STAILQ_HEAD(primaries, udf_pri_vol) primaries; /* linked list of primary volumes associated */
SLIST_HEAD(parts, udf_partition) parts; /* linked list of partitions descriptors */
SLIST_ENTRY(udf_volumeset) next_volumeset; /* for volumeset list */
};
/*
* Provides udf_session :: -> [(disc, anchor, tracknum)]
*/
struct udf_session {
struct udf_discinfo *disc;
struct anchor_vdp anchor;
uint16_t session_num;
uint32_t session_offset;
uint32_t session_length;
int writable;
/* physical layer read/write cache */
UDF_MUTEX(session_cache_lock);
/* SIMPLE cache */
uint32_t cache_line_r_start;
uint32_t cache_line_r_present;
uint8_t *cache_line_read;
uint32_t cache_line_w_start;
uint32_t cache_line_w_present;
uint32_t cache_line_w_dirty;
uint8_t *cache_line_write;
struct udf_wrcallback cache_write_callbacks[UDF_READWRITE_LINE_LENGTH+1];
STAILQ_ENTRY(udf_session) next_session; /* sessions are added at tail to preserve order */
};
/*---------------------------------------------------------------------*/
/* exported functions */
extern int udf_check_tag(union dscrptr *dscr);
extern int udf_check_tag_payload(union dscrptr *dscr);
extern int udf_check_tag_presence(union dscrptr *dscr, int TAG);
extern int udf_check_session_range(char *range);
/* XXX new kernel like interface XXX */
extern int udf_read_file_part_uio(struct udf_node *udf_node, char *what, int cachehints, struct uio *data_uio);
extern int udf_write_file_part_uio(struct udf_node *udf_node, char *what, int cachehints, struct uio *data_uio);
extern void udf_dispose_udf_node(struct udf_node *udf_node);
extern int udf_getattr(struct udf_node *udf_node, struct stat *stat);
extern int udf_readdir(struct udf_node *udf_node, struct uio *result_uio, int *eof_res /* int *cookies, int ncookies */);
//extern int udf_lookup_name_in_dir(struct udf_node *dir_node, struct udf_node **vnode, char *name); /* not fully VOP_LOOKUP yet */
extern int udf_lookup_name_in_dir(struct udf_node *dir_node, char *name, int namelen, struct long_ad *icb_loc, struct fileid_desc *fid, int *found);
extern int udf_readin_udf_node(struct udf_node *dir_node, struct long_ad *udf_icbptr, struct fileid_desc *fid, struct udf_node **res_sub_node);
extern int udf_sync_udf_node(struct udf_node *udf_node, char *why); /* writeout node */
extern int udf_truncate_node(struct udf_node *udf_node, uint64_t length /* ,ioflags */);
extern int udf_remove_file(struct udf_node *parent_node, struct udf_node *udf_node, char *componentname);
extern int udf_remove_directory(struct udf_node *dir_node, struct udf_node *udf_node, char *componentname);
extern int udf_create_file(struct udf_node *dir_node, char *componentname, struct stat *stat, struct udf_node **new_node);
extern int udf_create_directory(struct udf_node *dir_node, char *componentname, struct stat *stat, struct udf_node **new_node);
extern int udf_rename(struct udf_node *old_parent, struct udf_node *rename_me, char *old_name, struct udf_node *new_parent, struct udf_node *present, char *new_name);
extern int udf_unlink_node(struct udf_node *udf_node);
extern int udf_read_session_sector(struct udf_session *udf_session, uint32_t sector, char *what, uint8_t *buffer, int prefetch_sectors, int rwflags);
extern int udf_write_session_sector(struct udf_session *udf_session, uint32_t sector, char *what, uint8_t *source, int rwflags, struct udf_wrcallback *wrcallback);
extern int udf_read_logvol_sector(struct udf_log_vol *udf_log_vol, uint32_t vpart_num, uint32_t lb_num, char *what, uint8_t *buffer, uint32_t prefetch_sectors, int rwflags);
extern int udf_write_logvol_sector(struct udf_log_vol *udf_log_vol, uint32_t vpart_num, uint32_t lb_num, char *what, uint8_t *buffer, int rwflags, struct udf_wrcallback *wrcallback);
/* call back */
extern int udf_writeout_file_buffer(struct udf_node *udf_node, char *what, int rwflags, struct udf_buf *buf_entry);
/* special cases like VRS */
extern int udf_write_session_cache_sector(struct udf_session *udf_session, uint32_t sector, char *what, uint8_t *source, int flags, struct udf_wrcallback *wrcallback);
/* device/disc opener, closer and read/write operations */
extern void udf_init(void); /* call me first! */
extern int udf_mount_disc(char *devname, char *range, uint32_t sector_size, int mnt_flags, struct udf_discinfo **disc);
extern int udf_dismount_disc(struct udf_discinfo *disc);
extern int udf_open_disc(char *devname, int discop_flags, struct udf_discinfo **disc);
extern int udf_close_disc(struct udf_discinfo *disc);
extern int udf_sync_disc(struct udf_discinfo *disc);
extern int udf_sync_logvol(struct udf_log_vol *udf_log_vol);
extern int udf_sync_caches(struct udf_log_vol *udf_log_vol);
extern int udf_open_logvol(struct udf_log_vol *udf_log_vol);
extern int udf_close_logvol(struct udf_log_vol *udf_log_vol);
extern int udf_sync_logvol(struct udf_log_vol *udf_log_vol);
/* readers/writers helper functions */
extern int udf_init_session_caches(struct udf_session *udf_session);
extern int udf_writeout_udf_node(struct udf_node *udf_node, char *why);
extern int udf_sync_space_tables(struct udf_log_vol *udf_log_vol); /* read comment on definition */
extern int udf_logvol_vpart_to_partition(struct udf_log_vol *udf_log_vol, uint32_t vpart_num, struct udf_part_mapping **udf_part_mapping_ptr, struct udf_partition **udf_partition_ptr);
extern int udf_vpartoff_to_sessionoff(struct udf_log_vol *udf_log_vol, struct udf_part_mapping *udf_part_mapping, struct udf_partition *udf_partition, uint64_t offset, uint64_t *ses_off, uint64_t *trans_valid_len);
extern int udf_read_session_descriptor(struct udf_session *udf_session, uint32_t lb_num, char *what, union dscrptr **dscr, uint32_t *length);
extern int udf_read_logvol_descriptor(struct udf_log_vol *udf_log_vol, uint32_t vpart_num, uint32_t lb_num, char *what, union dscrptr **dscr, uint32_t *length);
extern int udf_write_session_descriptor(struct udf_session *udf_session, uint32_t lb_num, char *what, union dscrptr *dscr, struct udf_wrcallback *wrcallback);
extern int udf_write_partition_descriptor(struct udf_partition *udf_partition, uint32_t lb_num, char *what, union dscrptr *dscr, struct udf_wrcallback *wrcallback);
extern int udf_write_logvol_descriptor(struct udf_log_vol *udf_log_vol, uint32_t vpart_num, uint32_t lb_num, char *what, union dscrptr *dscr, struct udf_wrcallback *wrcallback);
/* exported text-dump functions */
extern void udf_dump_volume_name(char *prefix, struct udf_log_vol *udf_log_vol);
extern void udf_dump_long_ad(char *prefix, struct long_ad *adr);
extern void udf_dump_id(char *prefix, int len, char *id, struct charspec *chsp);
extern void udf_to_unix_name(char *result, char *id, int len, struct charspec *chsp);
/* exported descriptor creators */
extern int udf_validate_tag_sum(union dscrptr *dscr);
extern int udf_validate_tag_and_crc_sums(union dscrptr *dscr);
extern uint64_t udf_calc_tag_malloc_size(union dscrptr *dscr, uint32_t udf_sector_size);
extern int udf_read_fid_stream(struct udf_node *dir_node, uint64_t *offset, struct fileid_desc *fid, struct dirent *dirent);
extern void udf_resync_fid_stream(uint8_t *buffer, uint32_t *fid_pos, uint32_t max_fid_pos, int *fid_found);
extern int udf_create_empty_anchor_volume_descriptor(uint32_t sector_size, uint16_t dscr_ver, uint32_t main_vds_loc, uint32_t reserve_vds_loc, uint32_t length, struct anchor_vdp **vdp);
extern int udf_create_empty_primary_volume_descriptor(uint32_t sector_size, uint16_t dscr_ver, uint16_t serial, char *volset_id, char *privol_name, int vds_num, int max_vol_seq, struct pri_vol_desc **dscrptr);
extern int udf_create_empty_partition_descriptor(uint32_t sector_size, uint16_t dscr_ver, uint16_t serial, uint16_t part_num, uint32_t access_type, uint32_t start_loc, uint32_t part_len, uint32_t space_bitmap_size, uint32_t unalloc_space_bitmap, struct part_desc **dscrptr);
extern int udf_create_empty_unallocated_space_descriptor(uint32_t sector_size, uint16_t dscr_ver, uint16_t serial, struct unalloc_sp_desc **dscrptr);
extern int udf_create_empty_implementation_use_volume_descriptor(uint32_t sector_size, uint16_t dscr_ver, uint16_t serial, char *logvol_name, struct impvol_desc **dscrptr);
extern int udf_create_empty_logical_volume_descriptor(uint32_t sector_size, uint16_t dscr_ver, uint16_t serial, char *logvol_name, uint32_t lb_size, uint32_t integrity_start, uint32_t integrity_length, struct logvol_desc **dscrptr);
extern int udf_create_empty_space_bitmap(uint32_t sector_size, uint16_t dscr_ver, uint32_t num_lbs, struct space_bitmap_desc **dscrptr);
extern int udf_create_empty_terminator_descriptor(uint32_t sector_size, uint16_t dscr_ver, struct desc_tag **tag);
extern int udf_create_empty_fileset_desc(uint32_t sector_size, uint16_t dscr_ver, uint32_t fileset_num, char *logvol_name, char *fileset_name, struct fileset_desc **dscrptr);
extern void udf_add_physical_to_logvol(struct logvol_desc *logvol, uint16_t vol_seq_num, uint16_t phys_part_num);
extern void udf_derive_new_logvol_integrity(struct udf_log_vol *udf_log_vol);
/* time related creator functions */
extern void udf_set_timespec_now(struct timespec *timespec);
extern void udf_set_timestamp_now(struct timestamp *timestamp);
/* exported processing functions */
extern int udf_proc_pri_vol(struct udf_session *udf_session, struct udf_pri_vol **current, struct pri_vol_desc *incomming);
extern int udf_proc_part(struct udf_pri_vol *primary, struct udf_partition **current, struct part_desc *incomming);
extern int udf_proc_log_vol(struct udf_pri_vol *primary, struct udf_log_vol ** current, struct logvol_desc *incomming);
extern int udf_proc_filesetdesc(struct udf_log_vol *udf_log_vol, struct fileset_desc *incomming);
extern int udf_sync_space_bitmap(struct udf_alloc_entries *queue, struct space_bitmap_desc *sbd, uint32_t lb_size);
/* exported builders */
extern int udf_init_udf_node(struct udf_mountpoint *mountpoint, struct udf_log_vol *udf_log_vol, char *what, struct udf_node **udf_nodeptr);
extern void udf_insert_node_in_hash(struct udf_node *udf_node);
extern int udf_allocate_udf_node_on_disc(struct udf_node *udf_node);
extern void udf_node_mark_dirty(struct udf_node *udf_node);
extern int udf_allocate_lbs(struct udf_log_vol *udf_log_vol, int content, uint32_t req_lbs, char *what, uint16_t *res_vpart_num, uint32_t *res_start_lb, uint32_t *res_num_lbs);
extern int udf_node_allocate_lbs(struct udf_node *udf_node, int req_lbs, uint16_t *res_vpart_num, uint32_t *res_start_lb, uint32_t *res_num_lbs);
extern int udf_release_lbs(struct udf_log_vol *udf_log_vol, uint16_t vpart_num, uint32_t lb_num, uint64_t size);
extern int udf_node_release_extent(struct udf_node *udf_node, uint64_t from, uint64_t to);
extern int udf_confirm_freespace(struct udf_log_vol *udf_log_vol, int content, uint64_t size);
extern int udf_create_directory_entry(struct udf_node *dir_node, char *componentname, int filetype, int filechar, struct udf_node *refering, struct stat *stat, struct udf_node **new_node);
extern int udf_unlink_node(struct udf_node *udf_node);
extern uint64_t udf_increment_unique_id(struct udf_log_vol *udf_log_vol);
/* exported (temp) allocentries */
extern void udf_merge_allocentry_queue(struct udf_alloc_entries *queue, uint32_t lb_size);
extern int udf_cut_allocentry_queue(struct udf_alloc_entries *queue, uint32_t lb_size, uint64_t offset);
extern void udf_dump_allocentry_queue(char *msg, struct udf_alloc_entries *queue, uint32_t lb_size);
extern int udf_filepart_mark_extent(struct udf_node *udf_node, uint64_t data_offset, uint64_t data_length, int mark);
extern int udf_splitup_allocentry_queue(struct udf_alloc_entries *queue, uint32_t lb_size, uint64_t data_offset, uint64_t data_length, struct udf_allocentry **res_firstae, struct udf_allocentry **res_lastae);
extern int udf_mark_allocentry_queue(struct udf_alloc_entries *queue, uint32_t lb_size, uint64_t data_offset, uint64_t data_length, int mark, struct udf_allocentry **res_firstae, struct udf_allocentry **res_lastae);
extern int udf_extent_properties(struct udf_alloc_entries *queue, uint32_t lb_size, uint64_t from, uint64_t to, int *res_all_allocated);
/* define static list types and structures */
SLIST_HEAD(discslist, udf_discinfo);
SLIST_HEAD(volumeset_list, udf_volumeset);
SLIST_HEAD(mountables_list, udf_mountpoint);
extern struct discslist udf_discs_list;
extern struct volumeset_list udf_volumeset_list;
extern struct mountables_list udf_mountables;
#endif /* _UDF_H_ */
| 42.121643 | 275 | 0.756929 |
83af9f8e51849ef4d73f459fd56bd48c72bfd7e1 | 52,860 | h | C | code/include/playfab/PFCharacter.h | jasonsandlin/PlayFabCoreCSdk | ecf51e9a7a90e579efed595bd1d76ec8f3a1ae19 | [
"Apache-2.0"
] | null | null | null | code/include/playfab/PFCharacter.h | jasonsandlin/PlayFabCoreCSdk | ecf51e9a7a90e579efed595bd1d76ec8f3a1ae19 | [
"Apache-2.0"
] | null | null | null | code/include/playfab/PFCharacter.h | jasonsandlin/PlayFabCoreCSdk | ecf51e9a7a90e579efed595bd1d76ec8f3a1ae19 | [
"Apache-2.0"
] | null | null | null | // Copyright (c) Microsoft Corporation
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#if !defined(__cplusplus)
#error C++11 required
#endif
#pragma once
#include <playfab/PFCharacterDataModels.h>
#include <playfab/PFGlobal.h>
#include <playfab/PFTitlePlayer.h>
extern "C"
{
#if HC_PLATFORM != HC_PLATFORM_GDK
/// <summary>
/// Completely removes all statistics for the specified character, for the current game
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Note that this action cannot be un-done. All statistics for this character will be deleted, removing
/// the user from all leaderboards for the game.
///
/// Call <see cref="XAsyncGetStatus"/> to get the status of the operation.
/// </remarks>
HRESULT PFCharacterAdminResetCharacterStatisticsAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterResetCharacterStatisticsRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
#endif
/// <summary>
/// Lists all of the characters that belong to a specific user. CharacterIds are not globally unique;
/// characterId must be evaluated with the parent PlayFabId to guarantee uniqueness.
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Returns a list of every character that currently belongs to a user.
///
/// If successful, call <see cref="PFCharacterClientGetAllUsersCharactersGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterClientGetAllUsersCharactersAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterListUsersCharactersRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ClientGetAllUsersCharacters call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterClientGetAllUsersCharactersGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterClientGetAllUsersCharactersAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterClientGetAllUsersCharactersGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterListUsersCharactersResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves the title-specific custom data for the character which is readable and writable by the
/// client
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Data is stored as JSON key-value pairs. If the Keys parameter is provided, the data object returned
/// will only contain the data specific to the indicated Keys. Otherwise, the full set of custom character
/// data will be returned. See also ClientGetCharacterReadOnlyDataAsync, ClientGetUserDataAsync, ClientUpdateCharacterDataAsync.
///
/// If successful, call <see cref="PFCharacterClientGetCharacterDataGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterClientGetCharacterDataAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterGetCharacterDataRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ClientGetCharacterData call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterClientGetCharacterDataGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterClientGetCharacterDataAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterClientGetCharacterDataGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterClientGetCharacterDataResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves a list of ranked characters for the given statistic, starting from the indicated point
/// in the leaderboard
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// If successful, call <see cref="PFCharacterClientGetCharacterLeaderboardGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterClientGetCharacterLeaderboardAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterGetCharacterLeaderboardRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ClientGetCharacterLeaderboard call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterClientGetCharacterLeaderboardGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterClientGetCharacterLeaderboardAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterClientGetCharacterLeaderboardGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterGetCharacterLeaderboardResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves the title-specific custom data for the character which can only be read by the client
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Data is stored as JSON key-value pairs. If the Keys parameter is provided, the data object returned
/// will only contain the data specific to the indicated Keys. Otherwise, the full set of custom character
/// data will be returned. See also ClientGetCharacterDataAsync, ClientGetUserDataAsync, ClientUpdateCharacterDataAsync.
///
/// If successful, call <see cref="PFCharacterClientGetCharacterReadOnlyDataGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterClientGetCharacterReadOnlyDataAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterGetCharacterDataRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ClientGetCharacterReadOnlyData call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterClientGetCharacterReadOnlyDataGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterClientGetCharacterReadOnlyDataAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterClientGetCharacterReadOnlyDataGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterClientGetCharacterDataResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves the details of all title-specific statistics for the user
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// If successful, call <see cref="PFCharacterClientGetCharacterStatisticsGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterClientGetCharacterStatisticsAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterClientGetCharacterStatisticsRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ClientGetCharacterStatistics call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterClientGetCharacterStatisticsGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterClientGetCharacterStatisticsAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterClientGetCharacterStatisticsGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterClientGetCharacterStatisticsResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves a list of ranked characters for the given statistic, centered on the requested Character
/// ID
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// If successful, call <see cref="PFCharacterClientGetLeaderboardAroundCharacterGetResult"/> to get
/// the result.
/// </remarks>
HRESULT PFCharacterClientGetLeaderboardAroundCharacterAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterClientGetLeaderboardAroundCharacterRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ClientGetLeaderboardAroundCharacter call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterClientGetLeaderboardAroundCharacterGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterClientGetLeaderboardAroundCharacterAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterClientGetLeaderboardAroundCharacterGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterGetLeaderboardAroundCharacterResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves a list of all of the user's characters for the given statistic.
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// If successful, call <see cref="PFCharacterClientGetLeaderboardForUserCharactersGetResult"/> to get
/// the result.
/// </remarks>
HRESULT PFCharacterClientGetLeaderboardForUserCharactersAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterClientGetLeaderboardForUsersCharactersRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ClientGetLeaderboardForUserCharacters call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterClientGetLeaderboardForUserCharactersGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterClientGetLeaderboardForUserCharactersAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterClientGetLeaderboardForUserCharactersGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterGetLeaderboardForUsersCharactersResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Grants the specified character type to the user. CharacterIds are not globally unique; characterId
/// must be evaluated with the parent PlayFabId to guarantee uniqueness.
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Grants a character to the user of the type specified by the item ID. The user must already have an
/// instance of this item in their inventory in order to allow character creation. This item can come
/// from a purchase or grant, which must be done before calling to create the character.
///
/// If successful, call <see cref="PFCharacterClientGrantCharacterToUserGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterClientGrantCharacterToUserAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterClientGrantCharacterToUserRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ClientGrantCharacterToUser call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterClientGrantCharacterToUserGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterClientGrantCharacterToUserAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterClientGrantCharacterToUserGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterClientGrantCharacterToUserResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Creates and updates the title-specific custom data for the user's character which is readable and
/// writable by the client
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// This function performs an additive update of the arbitrary strings containing the custom data for
/// the character. In updating the custom data object, keys which already exist in the object will have
/// their values overwritten, while keys with null values will be removed. New keys will be added, with
/// the given values. No other key-value pairs will be changed apart from those specified in the call.
/// See also ClientGetCharacterDataAsync, ClientGetCharacterReadOnlyDataAsync, ClientGetUserDataAsync.
///
/// If successful, call <see cref="PFCharacterClientUpdateCharacterDataGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterClientUpdateCharacterDataAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterClientUpdateCharacterDataRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterClientUpdateCharacterDataAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="result">PFCharacterUpdateCharacterDataResult object that will be populated with the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterClientUpdateCharacterDataGetResult(
_Inout_ XAsyncBlock* async,
_Out_ PFCharacterUpdateCharacterDataResult* result
) noexcept;
/// <summary>
/// Updates the values of the specified title-specific statistics for the specific character. By default,
/// clients are not permitted to update statistics. Developers may override this setting in the Game Manager
/// > Settings > API Features.
/// </summary>
/// <param name="entityHandle">PFTitlePlayerHandle to use for authentication.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Enable this option with the 'Allow Client to Post Player Statistics' option in PlayFab GameManager
/// for your title. However, this is not best practice, as this data will no longer be safely controlled
/// by the server. This operation is additive. Character Statistics not currently defined will be added,
/// while those already defined will be updated with the given values. All other user statistics will
/// remain unchanged. Character statistics are used by the character-leaderboard apis, and accessible
/// for custom game-logic.
///
/// Call <see cref="XAsyncGetStatus"/> to get the status of the operation.
/// </remarks>
HRESULT PFCharacterClientUpdateCharacterStatisticsAsync(
_In_ PFTitlePlayerHandle titlePlayerHandle,
_In_ const PFCharacterClientUpdateCharacterStatisticsRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Deletes the specific character ID from the specified user.
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// This function will delete the specified character from the list allowed by the user, and will also
/// delete any inventory or VC currently held by that character. It will NOT delete any statistics associated
/// for this character, in order to preserve leaderboard integrity.
///
/// Call <see cref="XAsyncGetStatus"/> to get the status of the operation.
/// </remarks>
HRESULT PFCharacterServerDeleteCharacterFromUserAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterDeleteCharacterFromUserRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Lists all of the characters that belong to a specific user. CharacterIds are not globally unique;
/// characterId must be evaluated with the parent PlayFabId to guarantee uniqueness.
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Returns a list of every character that currently belongs to a user.
///
/// If successful, call <see cref="PFCharacterServerGetAllUsersCharactersGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterServerGetAllUsersCharactersAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterListUsersCharactersRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ServerGetAllUsersCharacters call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerGetAllUsersCharactersGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerGetAllUsersCharactersAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterServerGetAllUsersCharactersGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterListUsersCharactersResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves the title-specific custom data for the user which is readable and writable by the client
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Data is stored as JSON key-value pairs. If the Keys parameter is provided, the data object returned
/// will only contain the data specific to the indicated Keys. Otherwise, the full set of custom user
/// data will be returned. See also ServerGetUserDataAsync, ServerUpdateCharacterDataAsync, ServerUpdateCharacterInternalDataAsync,
/// ServerUpdateCharacterReadOnlyDataAsync.
///
/// If successful, call <see cref="PFCharacterServerGetCharacterDataGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterServerGetCharacterDataAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterGetCharacterDataRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ServerGetCharacterData call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerGetCharacterDataGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerGetCharacterDataAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterServerGetCharacterDataGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterServerGetCharacterDataResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves the title-specific custom data for the user's character which cannot be accessed by the
/// client
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Data is stored as JSON key-value pairs. If the Keys parameter is provided, the data object returned
/// will only contain the data specific to the indicated Keys. Otherwise, the full set of custom user
/// data will be returned. See also ServerGetUserInternalDataAsync, ServerUpdateCharacterDataAsync, ServerUpdateCharacterInternalDataAsync,
/// ServerUpdateCharacterReadOnlyDataAsync.
///
/// If successful, call <see cref="PFCharacterServerGetCharacterInternalDataGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterServerGetCharacterInternalDataAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterGetCharacterDataRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ServerGetCharacterInternalData call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerGetCharacterInternalDataGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerGetCharacterInternalDataAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterServerGetCharacterInternalDataGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterServerGetCharacterDataResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves a list of ranked characters for the given statistic, starting from the indicated point
/// in the leaderboard
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// See also ServerGetCharacterStatisticsAsync, ServerGetLeaderboardAroundCharacterAsync, ServerUpdateCharacterStatisticsAsync.
///
/// If successful, call <see cref="PFCharacterServerGetCharacterLeaderboardGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterServerGetCharacterLeaderboardAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterGetCharacterLeaderboardRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ServerGetCharacterLeaderboard call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerGetCharacterLeaderboardGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerGetCharacterLeaderboardAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterServerGetCharacterLeaderboardGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterGetCharacterLeaderboardResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves the title-specific custom data for the user's character which can only be read by the client
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Data is stored as JSON key-value pairs. If the Keys parameter is provided, the data object returned
/// will only contain the data specific to the indicated Keys. Otherwise, the full set of custom data
/// will be returned. See also ServerGetCharacterDataAsync, ServerGetCharacterInternalDataAsync, ServerGetUserReadOnlyDataAsync,
/// ServerUpdateCharacterReadOnlyDataAsync.
///
/// If successful, call <see cref="PFCharacterServerGetCharacterReadOnlyDataGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterServerGetCharacterReadOnlyDataAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterGetCharacterDataRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ServerGetCharacterReadOnlyData call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerGetCharacterReadOnlyDataGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerGetCharacterReadOnlyDataAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterServerGetCharacterReadOnlyDataGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterServerGetCharacterDataResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves the details of all title-specific statistics for the specific character
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Character statistics are similar to user statistics in that they are numeric values which may only
/// be updated by a server operation, in order to minimize the opportunity for unauthorized changes. In
/// addition to being available for use by the title, the statistics are used for all leaderboard operations
/// in PlayFab. See also ServerGetLeaderboardAsync, ServerGetUserStatisticsAsync, ServerUpdateCharacterStatisticsAsync.
///
/// If successful, call <see cref="PFCharacterServerGetCharacterStatisticsGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterServerGetCharacterStatisticsAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterServerGetCharacterStatisticsRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ServerGetCharacterStatistics call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerGetCharacterStatisticsGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerGetCharacterStatisticsAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterServerGetCharacterStatisticsGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterServerGetCharacterStatisticsResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves a list of ranked characters for the given statistic, centered on the requested user
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// See also ServerGetCharacterLeaderboardAsync, ServerGetLeaderboardAsync, ServerUpdateCharacterStatisticsAsync.
///
/// If successful, call <see cref="PFCharacterServerGetLeaderboardAroundCharacterGetResult"/> to get
/// the result.
/// </remarks>
HRESULT PFCharacterServerGetLeaderboardAroundCharacterAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterServerGetLeaderboardAroundCharacterRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ServerGetLeaderboardAroundCharacter call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerGetLeaderboardAroundCharacterGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerGetLeaderboardAroundCharacterAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterServerGetLeaderboardAroundCharacterGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterGetLeaderboardAroundCharacterResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Retrieves a list of all of the user's characters for the given statistic.
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// See also ServerGetLeaderboardAsync, ServerGetLeaderboardAroundCharacterAsync, ServerUpdateCharacterStatisticsAsync.
///
/// If successful, call <see cref="PFCharacterServerGetLeaderboardForUserCharactersGetResult"/> to get
/// the result.
/// </remarks>
HRESULT PFCharacterServerGetLeaderboardForUserCharactersAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterServerGetLeaderboardForUsersCharactersRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ServerGetLeaderboardForUserCharacters call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerGetLeaderboardForUserCharactersGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerGetLeaderboardForUserCharactersAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterServerGetLeaderboardForUserCharactersGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterGetLeaderboardForUsersCharactersResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Grants the specified character type to the user. CharacterIds are not globally unique; characterId
/// must be evaluated with the parent PlayFabId to guarantee uniqueness.
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Grants a character to the user of the type and name specified in the request.
///
/// If successful, call <see cref="PFCharacterServerGrantCharacterToUserGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterServerGrantCharacterToUserAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterServerGrantCharacterToUserRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Get the size in bytes needed to store the result of a ServerGrantCharacterToUser call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The buffer size in bytes required for the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerGrantCharacterToUserGetResultSize(
_Inout_ XAsyncBlock* async,
_Out_ size_t* bufferSize
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerGrantCharacterToUserAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="bufferSize">The size of the buffer for the result object.</param>
/// <param name="buffer">Byte buffer used for the result value and its fields.</param>
/// <param name="result">Pointer to the result object.</param>
/// <param name="bufferUsed">The number of bytes in the provided buffer that were used.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// result is a pointer within buffer and does not need to be freed separately.
/// </remarks>
HRESULT PFCharacterServerGrantCharacterToUserGetResult(
_Inout_ XAsyncBlock* async,
_In_ size_t bufferSize,
_Out_writes_bytes_to_(bufferSize, *bufferUsed) void* buffer,
_Outptr_ PFCharacterServerGrantCharacterToUserResult** result,
_Out_opt_ size_t* bufferUsed
) noexcept;
/// <summary>
/// Updates the title-specific custom data for the user's character which is readable and writable by
/// the client
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// This function performs an additive update of the arbitrary JSON object containing the custom data
/// for the user. In updating the custom data object, keys which already exist in the object will have
/// their values overwritten, while keys with null values will be removed. No other key-value pairs will
/// be changed apart from those specified in the call. See also ServerGetCharacterDataAsync, ServerUpdateCharacterInternalDataAsync,
/// ServerUpdateCharacterReadOnlyDataAsync, ServerUpdateUserDataAsync.
///
/// If successful, call <see cref="PFCharacterServerUpdateCharacterDataGetResult"/> to get the result.
/// </remarks>
HRESULT PFCharacterServerUpdateCharacterDataAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterServerUpdateCharacterDataRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerUpdateCharacterDataAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="result">PFCharacterUpdateCharacterDataResult object that will be populated with the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerUpdateCharacterDataGetResult(
_Inout_ XAsyncBlock* async,
_Out_ PFCharacterUpdateCharacterDataResult* result
) noexcept;
/// <summary>
/// Updates the title-specific custom data for the user's character which cannot be accessed by the client
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// This function performs an additive update of the arbitrary JSON object containing the custom data
/// for the user. In updating the custom data object, keys which already exist in the object will have
/// their values overwritten, keys with null values will be removed. No other key-value pairs will be
/// changed apart from those specified in the call. See also ServerGetCharacterInternalDataAsync, ServerUpdateCharacterDataAsync,
/// ServerUpdateCharacterReadOnlyDataAsync, ServerUpdateUserInternalDataAsync.
///
/// If successful, call <see cref="PFCharacterServerUpdateCharacterInternalDataGetResult"/> to get the
/// result.
/// </remarks>
HRESULT PFCharacterServerUpdateCharacterInternalDataAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterServerUpdateCharacterDataRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerUpdateCharacterInternalDataAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="result">PFCharacterUpdateCharacterDataResult object that will be populated with the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerUpdateCharacterInternalDataGetResult(
_Inout_ XAsyncBlock* async,
_Out_ PFCharacterUpdateCharacterDataResult* result
) noexcept;
/// <summary>
/// Updates the title-specific custom data for the user's character which can only be read by the client
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// This function performs an additive update of the arbitrary JSON object containing the custom data
/// for the user. In updating the custom data object, keys which already exist in the object will have
/// their values overwritten, keys with null values will be removed. No other key-value pairs will be
/// changed apart from those specified in the call. See also ServerGetCharacterDataAsync, ServerGetCharacterInternalDataAsync,
/// ServerGetCharacterReadOnlyDataAsync, ServerGetUserReadOnlyDataAsync.
///
/// If successful, call <see cref="PFCharacterServerUpdateCharacterReadOnlyDataGetResult"/> to get the
/// result.
/// </remarks>
HRESULT PFCharacterServerUpdateCharacterReadOnlyDataAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterServerUpdateCharacterDataRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
/// <summary>
/// Gets the result of a successful PFCharacterServerUpdateCharacterReadOnlyDataAsync call.
/// </summary>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <param name="result">PFCharacterUpdateCharacterDataResult object that will be populated with the result.</param>
/// <returns>Result code for this API operation.</returns>
HRESULT PFCharacterServerUpdateCharacterReadOnlyDataGetResult(
_Inout_ XAsyncBlock* async,
_Out_ PFCharacterUpdateCharacterDataResult* result
) noexcept;
/// <summary>
/// Updates the values of the specified title-specific statistics for the specific character
/// </summary>
/// <param name="stateHandle">PFStateHandle returned from PFInitialize call.</param>
/// <param name="request">Populated request object.</param>
/// <param name="async">XAsyncBlock for the async operation.</param>
/// <returns>Result code for this API operation.</returns>
/// <remarks>
/// Character statistics are similar to user statistics in that they are numeric values which may only
/// be updated by a server operation, in order to minimize the opportunity for unauthorized changes. In
/// addition to being available for use by the title, the statistics are used for all leaderboard operations
/// in PlayFab.
///
/// Call <see cref="XAsyncGetStatus"/> to get the status of the operation.
/// </remarks>
HRESULT PFCharacterServerUpdateCharacterStatisticsAsync(
_In_ PFStateHandle stateHandle,
_In_ const PFCharacterServerUpdateCharacterStatisticsRequest* request,
_Inout_ XAsyncBlock* async
) noexcept;
} | 48.185962 | 139 | 0.76224 |
260f55a5eb690375e64b119512c7e3a1044efaf3 | 951 | h | C | src/devices/ml/drivers/aml-nna/t931-nna-regs.h | allansrc/fuchsia | a2c235b33fc4305044d496354a08775f30cdcf37 | [
"BSD-2-Clause"
] | 210 | 2019-02-05T12:45:09.000Z | 2022-03-28T07:59:06.000Z | src/devices/ml/drivers/aml-nna/t931-nna-regs.h | allansrc/fuchsia | a2c235b33fc4305044d496354a08775f30cdcf37 | [
"BSD-2-Clause"
] | 56 | 2021-06-03T03:16:25.000Z | 2022-03-20T01:07:44.000Z | src/devices/ml/drivers/aml-nna/t931-nna-regs.h | allansrc/fuchsia | a2c235b33fc4305044d496354a08775f30cdcf37 | [
"BSD-2-Clause"
] | 73 | 2019-03-06T18:55:23.000Z | 2022-03-26T12:04:51.000Z | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_DEVICES_ML_DRIVERS_AML_NNA_T931_NNA_REGS_H_
#define SRC_DEVICES_ML_DRIVERS_AML_NNA_T931_NNA_REGS_H_
#include <zircon/types.h>
#include <hwreg/bitfields.h>
#include "aml-nna.h"
static aml_nna::AmlNnaDevice::NnaBlock T931NnaBlock{
// AO_RTI_GEN_PWR_SLEEP0
.domain_power_sleep_offset = 0x3a << 2,
// AO_RTI_GEN_PWR_ISO0
.domain_power_iso_offset = 0x3b << 2,
.domain_power_sleep_bits = (1 << 16) | (1 << 17),
.domain_power_iso_bits = (1 << 16) | (1 << 17),
// HHI_NANOQ_MEM_PD
.hhi_mem_pd_reg0_offset = 0x43 << 2,
.hhi_mem_pd_reg1_offset = 0x44 << 2,
// RESET2_LEVEL
.reset_level2_offset = 0x88,
// HHI_VIPNANOQ_CLK_CNTL
.clock_control_offset = 0x72 << 2,
};
#endif // SRC_DEVICES_ML_DRIVERS_AML_NNA_T931_NNA_REGS_H_
| 27.970588 | 73 | 0.722397 |
644fd58f8ae7db6fca7639e8f16e1034c6f8199b | 15,927 | c | C | reader.c | mQwand/Execore_Language | 364f938249e13d84fe51b525a5778d55ef6793d4 | [
"MIT"
] | null | null | null | reader.c | mQwand/Execore_Language | 364f938249e13d84fe51b525a5778d55ef6793d4 | [
"MIT"
] | null | null | null | reader.c | mQwand/Execore_Language | 364f938249e13d84fe51b525a5778d55ef6793d4 | [
"MIT"
] | null | null | null | //
// Created by Legion on 04.12.2021.
//
#include <ctype.h>
#include <string.h>
#include "id.h"
#include "reader.h"
#include "handle_err.h"
#include "src/utils/macro_utils.h"
#define SET_DEFAULT_VALUES(current_reader, source_lib) \
current_reader->source = NULL; \
current_reader->token = UNKNOWN; \
current_reader->last_peek = 0; \
current_reader->is_indent = true; \
current_reader->string[0] = 0; \
current_reader->total_indent = 0; \
current_reader->indentation[0] = 0; \
current_reader->source = source_lib
static struct {
char* keyword;
token_t token;
} keywords[] = {
{ "and", AND },
{ "break", BREAK },
{ "char", CHAR_INIT },
{ "continue", CONTINUE },
{ "def", FUNC_INIT },
{ "do", DO },
{ "else", ELSE },
{ "float", FLOAT_INIT },
{ "for", FOR },
{ "if", IF },
{ "import", IMPORT },
{ "in", IN },
{ "input", INPUT },
{ "int", INT_INIT },
{ "list", LIST_INIT},
{ "or", OR },
{ "pass", PASS },
{ "print", PRINT },
{ "return", RETURN },
{ "str", STR_INIT },
{ "while", WHILE }
};
static token_t ParseToken(char* buffer, int buffer_size);
static int rd_GetChar() {
REPORT(main_reader.source);
return main_reader.source->GetChar(main_reader.source);
}
static int rd_PeekChar() {
REPORT(main_reader.source);
return main_reader.source->PeekChar(main_reader.source);
}
static int rd_PushChar(const int symbol) {
REPORT(main_reader.source);
return main_reader.source->PushChar(main_reader.source, (char) symbol);
}
static void ConstructReader(reader* current_reader, library* source_lib) {
REPORT(current_reader);
*current_reader = main_reader;
SET_DEFAULT_VALUES(current_reader, source_lib);
}
static void CopyReader(reader* local_reader) {
REPORT(local_reader);
*local_reader = main_reader;
}
static void UploadReader(reader* local_reader) {
REPORT(local_reader);
main_reader = *local_reader;
}
static token_t GetToken() {
if (!main_reader.last_peek) {
main_reader.token = ParseToken(main_reader.string, sizeof(main_reader.string));
} else {
main_reader.token = main_reader.last_peek;
main_reader.last_peek = !main_reader.last_peek;
}
debug_printf(LEXER_DEBUG, "\ntoken: %s %s", tokenName(main_reader.token), main_reader.string);
return main_reader.token;
}
static token_t PeekToken() {
if (!main_reader.last_peek) {
main_reader.last_peek = ParseToken(main_reader.string, sizeof(main_reader.string));
}
return main_reader.last_peek;
}
static token_t GetString(char* string, int buffer_size) {
REPORT(string);
if (buffer_size < 2) {
MAKE_ERR("can't make string %s, size is %i :( \n", NAME(buffer_size), buffer_size);
}
int symbol = 0;
int count = 0;
buffer_size--;
/* getting string in cycle by chars, checking for escape sequences */
while (true) {
symbol = rd_GetChar();
if (symbol != EOF && symbol != '\"') {
if (symbol == '\\') {
switch (rd_PeekChar()) {
case '0' :
rd_GetChar();
symbol = '\0';
break;
case 'a' :
rd_GetChar();
symbol = '\a';
break;
case 'b' :
rd_GetChar();
symbol = '\b';
break;
case 'f' :
rd_GetChar();
symbol = '\f';
break;
case 'n' :
rd_GetChar();
symbol = '\n';
break;
case 'r' :
rd_GetChar();
symbol = '\r';
break;
case 't' :
rd_GetChar();
symbol = '\t';
break;
case 'v' :
rd_GetChar();
symbol = '\v';
break;
case '\\':
rd_GetChar();
symbol = '\\';
break;
case '\'':
rd_GetChar();
symbol = '\'';
break;
case '\"':
rd_GetChar();
symbol = '\"';
break;
}
}
if (count < buffer_size) {
string[count++] = (char) symbol;
}
} else {
string[count] = 0;
break;
}
}
return STR;
}
static token_t rd_GetNumber(char* number, int buffer_size) {
REPORT(number);
if (buffer_size < 2) {
MAKE_ERR("not enough memory allocated for the number: %s = %i \n", NAME(buffer_size), buffer_size);
}
int symbol = 0, exponent = 0, num_length = 0, count = 0;
buffer_size--;
while (true) {
symbol = rd_GetChar();
if (symbol != EOF && (isdigit(symbol) || symbol == '.')) {
if (symbol == '.') { {
if (++num_length > 1) {
RaiseError(VALUE_ERROR, "oh, cmon, why did you put extra decimal points here");
}
}
}
if (count < buffer_size)
number[count++] = (char) symbol;
} else {
if (symbol == 'e' || symbol == 'E') {
exponent = 1;
if (count < buffer_size)
number[count++] = (char) symbol;
symbol = rd_GetChar();
if (symbol == '-' || symbol == '+') {
if (count < buffer_size)
number[count++] = (char) symbol;
symbol = rd_GetChar();
}
if (!isdigit(symbol)) {
RaiseError(VALUE_ERROR, "where the fuck is exponent");
}
while (symbol != EOF && isdigit(symbol)) {
if (count < buffer_size) {
number[count++] = (char) symbol;
}
symbol = rd_GetChar();
}
}
number[count] = 0;
rd_PushChar(symbol);
break;
}
}
if (num_length == 1 || exponent == 1)
return FLOAT;
return INT;
}
/* binary FindLibrary is possible because of sorted names */
static int FindIdentifier(char* name, int* compare_result) {
int left = 0, right = 0, middle = 0;
right = sizeof (keywords) / sizeof (keywords[0]) - 1;;
while (left <= right) {
middle = (left + right) / 2;
/* strcmp() return difference between last chars, so result can be 0 (equal) or >0, or <0 */
*compare_result = strcmp(&name[0], keywords[middle].keyword);
if (*compare_result < 0) {
right = middle - 1;
}
if (*compare_result > 0) {
left = middle + 1;
}
if (!*compare_result) break;
}
return middle;
}
static token_t rd_GetId(char* name, int buffer_size) {
REPORT(name);
if (buffer_size < 2) {
MAKE_ERR("not enough memory allocated for the identifier: %s = %i \n", NAME(buffer_size), buffer_size);
}
int symbol = 0;
int id_length = 0;
buffer_size--;
while (true) {
symbol = rd_GetChar();
if (symbol != EOF && (isalnum(symbol) || symbol == '_')) {
if (id_length < buffer_size)
name[id_length++] = (char) symbol;
} else {
name[id_length] = 0;
rd_PushChar(symbol);
break;
}
}
int compare_result = 0;
int id_index = FindIdentifier(name, &compare_result);
if (!compare_result) {
name[0] = 0;
return keywords[id_index].token;
} else return IDENTIFIER;
}
static token_t GetSimpleChar(char* c, int buffer_size) {
REPORT(c);
if (buffer_size < 2) {
MAKE_ERR("not enough memory allocated for the identifier: %s = %i \n", NAME(buffer_size), buffer_size);
}
int symbol = 0;
symbol = rd_GetChar();
if (symbol == '\\') {
symbol = rd_GetChar();
switch (symbol) {
case '0' :
c[0] = '\0';
break;
case 'a' :
c[0] = '\a';
break;
case 'b' :
c[0] = '\b';
break;
case 'f' :
c[0] = '\f';
break;
case 'n' :
c[0] = '\n';
break;
case 'r' :
c[0] = '\r';
break;
case 't' :
c[0] = '\t';
break;
case 'v' :
c[0] = '\v';
break;
case '\\':
c[0] = '\\';
break;
case '\'':
c[0] = '\'';
break;
case '\"':
c[0] = '\"';
break;
default :
RaiseError(SYNTAX_ERROR, "I have no fucking idea what is that: %c", symbol);
break;
}
} else {
if (symbol == '\'' || symbol == EOF) {
RaiseError(SYNTAX_ERROR, "empty character constant");
} else *(c + 1) = (char) symbol;
}
symbol = rd_GetChar();
if (symbol != '\'')
RaiseError(SYNTAX_ERROR, "to many characters in character constant");
*(c + 1) = 0; // null-byte as a termination symbol
return CHAR;
}
static token_t ParseToken(char* buffer, int buffer_size) {
REPORT(buffer);
if (buffer_size < 2) {
MAKE_ERR("not enough memory allocated for the identifier: %s = %i \n", NAME(buffer_size), buffer_size);
}
int symbol = 0;
*buffer = 0;
while (main_reader.is_indent) {
int column = 0;
main_reader.is_indent = false;
while (true) {
symbol = rd_GetChar();
switch (symbol) {
case ' ':
column++;
break;
case '\t':
column += parser_configs.tab_size;
break;
default:
goto read_lines;
break;
}
}
read_lines:;
if (symbol == '#') {
while (symbol != '\n' && symbol != EOF) {
symbol = rd_GetChar();
}
}
if (symbol == '\r') {
symbol = rd_GetChar();
}
if (symbol == '\n') {
main_reader.is_indent = true;
continue;
} else if (symbol == EOF) {
column = 0;
if (column == main_reader.indentation[main_reader.total_indent]) {
return END_TRIGGER;
}
} else
rd_PushChar(symbol);
/* checking different variant of indentation (did it change?) */
if (column == main_reader.indentation[main_reader.total_indent]) break;
else if (column > main_reader.indentation[main_reader.total_indent]) {
if (main_reader.total_indent == TOTAL_IND_MAX) {
RaiseError(SYNTAX_ERROR, "no more indents for you, bozo!");
}
main_reader.indentation[++main_reader.total_indent] = column;
return INDENT;
} else {
if (--main_reader.total_indent < 0) {
RaiseError(SYNTAX_ERROR, "bro you are discrediting dumb, use tabs normally");
}
/* checking if modified indentation old or not */
if (column != main_reader.indentation[main_reader.total_indent]) {
main_reader.is_indent = true;
main_reader.source->buf_char_index = main_reader.source->buf_line_index;
}
return DEDENT;
}
}
do {
symbol = rd_GetChar();
} while (symbol == ' ' || symbol == '\t');
if (symbol == '#') {
while (symbol != '\n' && symbol != EOF) {
symbol = rd_GetChar();
}
}
/* just skip \r symbols */
if (symbol == '\r') {
symbol = rd_GetChar();
}
if (symbol == '\n') {
main_reader.is_indent = true;
return NEWLINE;
} else if (symbol == EOF) return END_TRIGGER;
if (isdigit(symbol)) {
rd_PushChar(symbol);
return rd_GetNumber(buffer, buffer_size);
} else if (isalpha(symbol)) {
rd_PushChar(symbol);
return rd_GetId(buffer, buffer_size);
} else {
switch (symbol) {
case '\'':
return GetSimpleChar(buffer, buffer_size);
case '\"':
return GetString(buffer, buffer_size);
case EOF :
return END_TRIGGER;
case '(' :
return LEFT_PAR;
case ')' :
return RIGHT_PAR;
case '[' :
return LEFT_SEQ_BLOCK;
case ']' :
return RIGHT_SEQ_BLOCK;
case ',' :
return COMMA;
case '.' :
return METHOD;
case ':' :
return COLON;
case '*' :
if (rd_PeekChar() == '=') {
rd_GetChar();
return STAR_EQUAL;
} else return STAR;
case '%' :
if (rd_PeekChar() == '=') {
rd_GetChar();
return PERCENT_EQUAL;
} else return PERCENT;
case '+' :
if (rd_PeekChar() == '=') {
rd_GetChar();
return PLUS_EQUAL;
} else return PLUS;
case '-' :
if (rd_PeekChar() == '=') {
rd_GetChar();
return MINUS_EQUAL;
} else return MINUS;
case '/' :
if (rd_PeekChar() == '=') {
rd_GetChar();
return SLASH_EQUAL;
} else return SLASH;
case '!' :
if (rd_PeekChar() == '=') {
rd_GetChar();
return NOT_EQUAL;
} else return NOT;
case '=' :
if (rd_PeekChar() == '=') {
rd_GetChar();
return EQUAL_EQUAL;
} else return EQUAL;
case '<' :
if (rd_PeekChar() == '=') {
rd_GetChar();
return LESS_EQUAL;
} else if (rd_PeekChar() == '>') {
rd_GetChar();
return NOT_EQUAL;
} else return LESS;
case '>' :
if (rd_PeekChar() == '=') {
rd_GetChar();
return GREATER_EQUAL;
} else return GREATER;
default:
MAKE_ERR("lol wtf is this: \'%c\'\n", symbol);
return UNKNOWN;
}
}
return UNKNOWN;
}
reader main_reader = {
.source = NULL,
.token = UNKNOWN,
.last_peek = 0,
.is_indent = true,
.string[0] = 0,
.total_indent = 0,
.indentation[0] = 0,
.GetToken = GetToken,
.PeekToken = PeekToken,
.MakeReader = ConstructReader,
.CopyReader = CopyReader,
.UploadReader = UploadReader
};
| 27.086735 | 118 | 0.445407 |
6c99c0c148c3c557ef5e288cfb340edb14d537f0 | 1,381 | c | C | examples/bramtest/jni/BtestRequest.c | cambridgehackers/atomicc-examples | d0280629b94185d806637486b8413dd1a806d82a | [
"MIT"
] | null | null | null | examples/bramtest/jni/BtestRequest.c | cambridgehackers/atomicc-examples | d0280629b94185d806637486b8413dd1a806d82a | [
"MIT"
] | null | null | null | examples/bramtest/jni/BtestRequest.c | cambridgehackers/atomicc-examples | d0280629b94185d806637486b8413dd1a806d82a | [
"MIT"
] | null | null | null | #include "GeneratedTypes.h"
int BtestRequest_read ( struct PortalInternal *p, const uint32_t addr )
{
volatile unsigned int* temp_working_addr_start = p->transport->mapchannelReq(p, CHAN_NUM_BtestRequest_read, 2);
volatile unsigned int* temp_working_addr = temp_working_addr_start;
if (p->transport->busywait(p, CHAN_NUM_BtestRequest_read, "BtestRequest_read")) return 1;
p->transport->write(p, &temp_working_addr, addr);
p->transport->send(p, temp_working_addr_start, (CHAN_NUM_BtestRequest_read << 16) | 2, -1);
return 0;
};
int BtestRequest_write ( struct PortalInternal *p, const uint32_t addr, const uint32_t data )
{
volatile unsigned int* temp_working_addr_start = p->transport->mapchannelReq(p, CHAN_NUM_BtestRequest_write, 3);
volatile unsigned int* temp_working_addr = temp_working_addr_start;
if (p->transport->busywait(p, CHAN_NUM_BtestRequest_write, "BtestRequest_write")) return 1;
p->transport->write(p, &temp_working_addr, addr);
p->transport->write(p, &temp_working_addr, data);
p->transport->send(p, temp_working_addr_start, (CHAN_NUM_BtestRequest_write << 16) | 3, -1);
return 0;
};
BtestRequestCb BtestRequestProxyReq = {
portal_disconnect,
BtestRequest_read,
BtestRequest_write,
};
BtestRequestCb *pBtestRequestProxyReq = &BtestRequestProxyReq;
const uint32_t BtestRequest_reqinfo = 0x2000c;
| 43.15625 | 116 | 0.75887 |
96f6579a2106e46b8fef409f5248d9a7f02fae0e | 924 | h | C | VisualStudio_Projekt/PCD2ASC/Processing.h | michaelrenoo/Softwareentwicklungsprojekt_WiSe19-20 | 5c10063178ad6b5091b0c96cdfc9165a07592566 | [
"BSD-4-Clause-UC"
] | null | null | null | VisualStudio_Projekt/PCD2ASC/Processing.h | michaelrenoo/Softwareentwicklungsprojekt_WiSe19-20 | 5c10063178ad6b5091b0c96cdfc9165a07592566 | [
"BSD-4-Clause-UC"
] | null | null | null | VisualStudio_Projekt/PCD2ASC/Processing.h | michaelrenoo/Softwareentwicklungsprojekt_WiSe19-20 | 5c10063178ad6b5091b0c96cdfc9165a07592566 | [
"BSD-4-Clause-UC"
] | null | null | null | #pragma once
#include <pcl/io/ply_io.h>
#include <string>
#include "ReferenceModel.h"
using namespace std;
class Processing
{
public:
pcl::PointCloud<pcl::PointXYZ>::Ptr transformationMatrix(pcl::PointCloud<pcl::PointXYZ>::Ptr);
pcl::PointCloud<pcl::PointXYZ>::Ptr plyReader(string&);
pcl::PointCloud<pcl::PointXYZ>::Ptr startScanning(string&);
pcl::PointCloud<pcl::PointXYZ>::Ptr removeBackground(pcl::PointCloud<pcl::PointXYZ>::Ptr);
void positioning();
ReferenceModel doICP(vector <ReferenceModel>);
private:
void determineRemovalParameters(pcl::PointCloud<pcl::PointXYZ>::Ptr);
pcl::PointCloud<pcl::PointXYZ>::Ptr extractGround(pcl::PointCloud<pcl::PointXYZ>::Ptr, pcl::PointCloud<pcl::PointXYZ>::Ptr);
void determineAngle(pcl::PointCloud<pcl::PointXYZ>::Ptr);
// Always rotate x first!
float angle_x;
float angle_y;
float x_min;
float x_max;
float z_min;
float z_max;
float y_min;
float y_max;
}; | 28 | 125 | 0.75 |
29dcc40b2aed5162bec38df5ffc1eade20c44416 | 717 | h | C | os.h | zorbathut/glorp | f8fc9981f07d9665583d98c92f3db2ced7cb7103 | [
"BSD-3-Clause"
] | 26 | 2015-04-22T04:22:05.000Z | 2021-11-19T16:28:47.000Z | os.h | zorbathut/glorp | f8fc9981f07d9665583d98c92f3db2ced7cb7103 | [
"BSD-3-Clause"
] | null | null | null | os.h | zorbathut/glorp | f8fc9981f07d9665583d98c92f3db2ced7cb7103 | [
"BSD-3-Clause"
] | 2 | 2017-11-27T21:22:25.000Z | 2020-09-24T00:15:26.000Z |
#include <string>
#include <vector>
using namespace std;
namespace Glorp {
// debug-type stuff
void outputDebug(const string &str);
void crash() __attribute__ ((noreturn));
void spawn(const string &exec, const vector<string> ¶ms);
void stackDump(vector<const void*> *data);
void stackOutput();
int exeSize();
string exeName();
// directories/fs
string directoryDesktop();
string directoryConfig();
void directoryConfigMake();
string directoryTempfile();
void directoryMkdir(const string &str);
string directoryDelimiter();
// performance
int memoryUsage();
bool isUnoptimized();
int64_t timeMicro();
void sleep(int ms);
// OS commands
void beginShutdown();
}
| 21.088235 | 63 | 0.702929 |
e45b58f1cccec24bd8230444da289acc3e84be31 | 3,166 | c | C | libcss/src/parse/properties/autogenerated_line_height.c | Unix4ever/libcss | 34258bb325c964500e0ae019471bb68ff664dbf6 | [
"MIT"
] | 1 | 2021-04-21T12:41:32.000Z | 2021-04-21T12:41:32.000Z | src/parse/properties/autogenerated_line_height.c | netsurf-plan9/libcss | d1aa279c1c880d4ab9644906acfdc10a3de37f09 | [
"MIT"
] | null | null | null | src/parse/properties/autogenerated_line_height.c | netsurf-plan9/libcss | d1aa279c1c880d4ab9644906acfdc10a3de37f09 | [
"MIT"
] | 1 | 2021-05-05T02:19:29.000Z | 2021-05-05T02:19:29.000Z | /*
* This file was generated by LibCSS gen_parser
*
* Generated from:
*
* line_height:CSS_PROP_LINE_HEIGHT IDENT:( INHERIT: NORMAL:0,LINE_HEIGHT_NORMAL IDENT:) NUMBER:( false:LINE_HEIGHT_NUMBER RANGE:num<0 NUMBER:) LENGTH_UNIT:( UNIT_PX:LINE_HEIGHT_DIMENSION DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ RANGE:<0 LENGTH_UNIT:)
*
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2010 The NetSurf Browser Project.
*/
#include <assert.h>
#include <string.h>
#include "bytecode/bytecode.h"
#include "bytecode/opcodes.h"
#include "parse/properties/properties.h"
#include "parse/properties/utils.h"
/**
* Parse line_height
*
* \param c Parsing context
* \param vector Vector of tokens to process
* \param ctx Pointer to vector iteration context
* \param result resulting style
* \return CSS_OK on success,
* CSS_NOMEM on memory exhaustion,
* CSS_INVALID if the input is not valid
*
* Post condition: \a *ctx is updated with the next token to process
* If the input is invalid, then \a *ctx remains unchanged.
*/
css_error css__parse_line_height(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result)
{
int orig_ctx = *ctx;
css_error error;
const css_token *token;
bool match;
token = parserutils_vector_iterate(vector, ctx);
if (token == NULL) {
*ctx = orig_ctx;
return CSS_INVALID;
}
if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[INHERIT], &match) == lwc_error_ok && match)) {
error = css_stylesheet_style_inherit(result, CSS_PROP_LINE_HEIGHT);
} else if ((token->type == CSS_TOKEN_IDENT) && (lwc_string_caseless_isequal(token->idata, c->strings[NORMAL], &match) == lwc_error_ok && match)) {
error = css__stylesheet_style_appendOPV(result, CSS_PROP_LINE_HEIGHT, 0,LINE_HEIGHT_NORMAL);
} else if (token->type == CSS_TOKEN_NUMBER) {
css_fixed num = 0;
size_t consumed = 0;
num = css__number_from_lwc_string(token->idata, false, &consumed);
/* Invalid if there are trailing characters */
if (consumed != lwc_string_length(token->idata)) {
*ctx = orig_ctx;
return CSS_INVALID;
}
if (num<0) {
*ctx = orig_ctx;
return CSS_INVALID;
}
error = css__stylesheet_style_appendOPV(result, CSS_PROP_LINE_HEIGHT, 0, LINE_HEIGHT_NUMBER);
if (error != CSS_OK) {
*ctx = orig_ctx;
return error;
}
error = css__stylesheet_style_append(result, num);
} else {
css_fixed length = 0;
uint32_t unit = 0;
*ctx = orig_ctx;
error = css__parse_unit_specifier(c, vector, ctx, UNIT_PX, &length, &unit);
if (error != CSS_OK) {
*ctx = orig_ctx;
return error;
}
if (unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ) {
*ctx = orig_ctx;
return CSS_INVALID;
}
if (length <0) {
*ctx = orig_ctx;
return CSS_INVALID;
}
error = css__stylesheet_style_appendOPV(result, CSS_PROP_LINE_HEIGHT, 0, LINE_HEIGHT_DIMENSION);
if (error != CSS_OK) {
*ctx = orig_ctx;
return error;
}
error = css__stylesheet_style_vappend(result, 2, length, unit);
}
if (error != CSS_OK)
*ctx = orig_ctx;
return error;
}
| 28.267857 | 267 | 0.708465 |
a078b2e90f6cbfc42b238e74b33579926e134cf1 | 8,006 | h | C | src/c/printing.h | rupea/LabelFilters | a70b1f90427fe44bd43fee842aad34704d51854c | [
"BSD-3-Clause"
] | 4 | 2019-04-23T01:32:47.000Z | 2019-12-12T07:02:52.000Z | src/c/printing.h | rupea/LabelFilters | a70b1f90427fe44bd43fee842aad34704d51854c | [
"BSD-3-Clause"
] | 1 | 2019-01-21T22:05:09.000Z | 2019-03-06T15:37:35.000Z | src/c/printing.h | rupea/LabelFilters | a70b1f90427fe44bd43fee842aad34704d51854c | [
"BSD-3-Clause"
] | null | null | null | /* Copyright (C) 2017 NEC Laboratories America, Inc. ("NECLA"). All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree. An additional grant of patent rights
* can be found in the PATENTS file in the same directory.
*/
#ifndef __PRINTING_H
#define __PRINTING_H
/** \file
* IO helpers -- not endian-safe, but please use these with portably-sized types.
*/
#include "typedefs.h"
#include "boolmatrix.h"
#include <boost/dynamic_bitset.hpp>
#include <string>
#include <iosfwd>
class Roaring;
namespace detail {
template<typename T> inline std::ostream& io_txt( std::ostream& os, T const& x, char const* ws="\n" );
template<typename T> inline std::istream& io_txt( std::istream& is, T & x );
template<typename T> inline std::ostream& io_bin( std::ostream& os, T const& x );
template<typename T> inline std::istream& io_bin( std::istream& is, T & x );
inline std::ostream& io_bin( std::ostream& os, void const* p, size_t bytes );
inline std::istream& io_bin( std::istream& is, void * p, size_t bytes );
// specializations
// strings as length + blob (no intervening space)
template<> std::ostream& io_txt( std::ostream& os, std::string const& x, char const* /*ws="\n"*/ );
template<> std::istream& io_txt( std::istream& is, std::string& x );
template<> std::ostream& io_bin( std::ostream& os, std::string const& x );
template<> std::istream& io_bin( std::istream& is, std::string& x );
/** \name Roaring i/o */
//@{
std::ostream& io_txt( std::ostream& os, Roaring const& x, char const* ws = "\n" );
std::istream& io_txt( std::istream& is, Roaring & x );
std::ostream& io_txt( std::ostream& os, std::vector<Roaring> const& x, char const* ws = "\n" );
std::istream& io_txt( std::istream& os, std::vector<Roaring> & x );
std::ostream& io_bin( std::ostream& os, Roaring const& x );
std::istream& io_bin( std::istream& is, Roaring & x );
std::ostream& io_bin( std::ostream& os, std::vector<Roaring> const& x );
std::istream& io_bin( std::istream& os, std::vector<Roaring> & x );
//@}
/** \name std::array<T,N> i/o
* specialized for array<char,N> to remove intervening ws. */
//@{
#define TARRAY template<class T, std::size_t N>
// std::array (fixed-size array, so size N is not part of stream)
TARRAY std::ostream& io_txt( std::ostream& os, std::array<T,N> const& x, char const* ws="\n" );
TARRAY std::istream& io_txt( std::istream& is, std::array<T,N> & x );
TARRAY std::ostream& io_bin( std::ostream& os, std::array<T,N> const& x );
TARRAY std::istream& io_bin( std::istream& is, std::array<T,N> & x );
#undef TARRAY
//@}
/** \name boolmatrix i/o.
* - boolmatrix is NOT dynamically sized, so on input, the "dimensions"
* MUST already be known. So:
* - [*] DO NOT store rows, cols --> trivial equiv. of i/o with boolmatrix::[c]base()
* - or STORE them and use throw on mismatch. */
//@{
template<> std::ostream& io_txt( std::ostream& os, boolmatrix const& x, char const* ws/*="\n"*/ );
template<> std::istream& io_txt( std::istream& is, boolmatrix& x );
template<> std::ostream& io_bin( std::ostream& os, boolmatrix const& x );
template<> std::istream& io_bin( std::istream& is, boolmatrix& x );
//@}
// Eigen DENSE matrix/vector/array
// Note: RAW data i/o only -- transpose flags etc. will not be stored) Also see
// http://stackoverflow.com/questions/22725867/eigen-type-deduction-in-template-specialization-of-base-class
/** \name Eigen Dense I/O
* - Eigen I/O for matrices [vectors] always with prepended row,col dimension.
* - If dimensions known before-hand \em could have a different set of I/O routines
* - Vectors get stored as single-column matrix
* - txt i/o prepends matrix dimension (unlike operators <<, >>)
* - \b Unsupported: binary i/o is coerced to/from float
* - \b Unsupported: special flags for matrix (sym, etc.)
* - \b Unsupported: retaining matrix properties (sym, row-wise, ...)
*/
//@{
#define TMATRIX template<typename Derived>
#define MATRIX Eigen::PlainObjectBase< Derived >
TMATRIX std::ostream& eigen_io_bin( std::ostream& os, MATRIX const& x );
TMATRIX std::istream& eigen_io_bin( std::istream& is, MATRIX & x );
TMATRIX std::ostream& eigen_io_txt( std::ostream& os, MATRIX const& x, char const *ws="\n" );
TMATRIX std::istream& eigen_io_txt( std::istream& is, MATRIX & x );
#undef MATRIX
#undef TMATRIX
//@}
/** \name Eigen Sparse I/O
* - binary i/o is coerced to/from float
* - output via Outer/InnerIterator (compressed) + innerNonZeroPtr (uncompressed)
* - input always forms a compressed matrix
* - \b Unsupported: special types of sparse matrix (sym,...)
* - \b Unsupported: retaining matrix properties (sym, row-wise, ...)
* \todo Eigen Sparse Idx i/o --> reduced byte size (in printing.hh)
* \todo Eigen Sparse bool values are irrelevant (once pruned), so files can be very short
*/
//@{
#define TMATRIX template<typename Scalar, int Options, typename Index>
#define MATRIX Eigen::SparseMatrix< Scalar, Options, Index >
TMATRIX std::ostream& eigen_io_bin( std::ostream& os, MATRIX const& x );
TMATRIX std::istream& eigen_io_bin( std::istream& is, MATRIX & x );
TMATRIX std::ostream& eigen_io_txt( std::ostream& os, MATRIX const& x, char const *ws="\n" );
TMATRIX std::istream& eigen_io_txt( std::istream& is, MATRIX & x );
/* template<int Options, typename Index> // bool override: */
/* std::ostream& eigen_io_bin( std::ostream& os, Eigen::SparseMatrix<bool,Options,Index> const& x ); */
/* template<int Options, typename Index> // bool override: */
/* std::istream& eigen_io_bin( std::istream& is, Eigen::SparseMatrix<bool,Options,Index> & x ); */
#undef MATRIX
#undef TMATRIX
template<typename Type>
std::istream& parse_labels(std::istream& iss, std::vector<Type>& yIdx);
template<typename Type>
std::istream& parse_features(std::istream& iss, std::vector<size_t>& xIdx, std::vector<Type>& xVal);
/** input only - read text libsvm-format. \throw on error. */
std::istream& eigen_read_libsvm( std::istream& is,
SparseM &x,
SparseMb &y,
int const verbose = 0);
}//detail::
// from EigenIO.h -- actually this is generic, not related to Eigen
// TODO portable types
template <typename Block, typename Alloc>
void save_bitvector(std::ostream& out, const boost::dynamic_bitset<Block, Alloc>& bs);
template <typename Block, typename Alloc>
int load_bitvector(std::istream& in, boost::dynamic_bitset<Block, Alloc>& bs);
void dumpFeasible(std::ostream& os
, std::vector<boost::dynamic_bitset<>> const& vbs
, bool denseFmt=false);
/// \name misc pretty printing
//@{
/** Prints the progress bar */
void print_progress(std::string s, int t, int max_t);
/** alt matrix dimension printer with an operator<<, as [MxN] */
struct PrettyDimensions {
friend std::ostream& operator<<(std::ostream& os, PrettyDimensions const& pd);
static uint_least8_t const maxDim=3U;
size_t dims[maxDim];
uint_least8_t dim;
};
template<typename EigenType> PrettyDimensions prettyDims( EigenType const& x );
std::ostream& operator<<(std::ostream& os, PrettyDimensions const& pd);
template< typename DERIVED >
std::string print_report(Eigen::SparseMatrixBase<DERIVED> const& x); ///< nnz for sparse matrix
template< typename EigenType > inline
std::string print_report(EigenType const& x); ///< empty string
void print_report(const int projection_dim, const int batch_size,
const int noClasses, const double C1, const double C2, const double lambda, const int w_size,
std::string x_report);
//@}
#endif
| 46.277457 | 112 | 0.655883 |
48e589abe962472e040116428c9ca1c16ca38920 | 4,553 | h | C | base/fs/rdr2/csc/record.mgr/ntcsc.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | base/fs/rdr2/csc/record.mgr/ntcsc.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | base/fs/rdr2/csc/record.mgr/ntcsc.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*++
Copyright (c) 1989 Microsoft Corporation
Module Name:
ntcsc.h
Abstract:
The global include file including the csc record manager
Author:
Revision History:
--*/
#ifndef __NTCSC_H__
#define __NTCSC_H__
//#include "ntifs.h"
#include "rx.h"
//if this is included from smbmini, we'll need this
#include "rxpooltg.h" // RX pool tag macros
#define WIN32_NO_STATUS
#define _WINNT_
#include "windef.h"
#include "winerror.h"
//both ntifs.h and ifs.h want to define these....sigh.......
#undef STATUS_PENDING
#undef FILE_ATTRIBUTE_READONLY
#undef FILE_ATTRIBUTE_HIDDEN
#undef FILE_ATTRIBUTE_SYSTEM
#undef FILE_ATTRIBUTE_DIRECTORY
#undef FILE_ATTRIBUTE_ARCHIVE
#include "ifs.h"
#define VxD
#define CSC_RECORDMANAGER_WINNT
#define CSC_ON_NT
// get rid of far references
#define far
//handle types
typedef ULONG DWORD;
// the VxD code likes to declare long pointers.....
typedef PVOID LPVOID;
typedef BYTE *LPBYTE;
//semaphore stuff....should be in a separate .h file
typedef PFAST_MUTEX VMM_SEMAPHORE;
INLINE
PFAST_MUTEX
Create_Semaphore (
ULONG count
)
{
PFAST_MUTEX fmutex;
ASSERT(count==1);
fmutex = (PFAST_MUTEX)RxAllocatePoolWithTag(
NonPagedPool,
sizeof(FAST_MUTEX),
RX_MISC_POOLTAG);
if (fmutex){
ExInitializeFastMutex(fmutex);
}
//DbgPrint("fmtux=%08lx\n",fmutex);
//ASSERT(!"here in init semaphore");
return fmutex;
}
#define Destroy_Semaphore(__sem) { RxFreePool(__sem);}
//Bug 498169 - changing to unsafe version of acquire and release mutex - navjotv
#define Wait_Semaphore(__sem, DUMMY___) {\
KeEnterCriticalRegion();\
ExAcquireFastMutexUnsafe(__sem);}
#define Signal_Semaphore(__sem) {\
ExReleaseFastMutexUnsafe(__sem);\
KeLeaveCriticalRegion();}
//#define Wait_Semaphore(__sem, DUMMY___) { ExAcquireFastMutex(__sem);}
//#define Signal_Semaphore(__sem) { ExReleaseFastMutex(__sem);}
//registry stuff.........again, will be a separate .h file
typedef DWORD VMMHKEY;
typedef VMMHKEY *PVMMHKEY;
typedef DWORD VMMREGRET; // return type for the REG Functions
#define MAX_VMM_REG_KEY_LEN 256 // includes the \0 terminator
#ifndef REG_SZ // define only if not there already
#define REG_SZ 0x0001
#endif
#ifndef REG_BINARY // define only if not there already
#define REG_BINARY 0x0003
#endif
#ifndef REG_DWORD // define only if not there already
#define REG_DWORD 0x0004
#endif
#ifndef HKEY_LOCAL_MACHINE // define only if not there already
#define HKEY_CLASSES_ROOT 0x80000000
#define HKEY_CURRENT_USER 0x80000001
#define HKEY_LOCAL_MACHINE 0x80000002
#define HKEY_USERS 0x80000003
#define HKEY_PERFORMANCE_DATA 0x80000004
#define HKEY_CURRENT_CONFIG 0x80000005
#define HKEY_DYN_DATA 0x80000006
#endif
//initially, we won't go to the registry!
#define _RegOpenKey(a,b,c) (ERROR_SUCCESS+1)
#define _RegQueryValueEx(a,b,c,d,e,f) (ERROR_SUCCESS+1)
#define _RegCloseKey(a) {NOTHING; }
// fix up the fact that stuff is conditioned on DEBUG and various...
#if DBG
#define DEBLEVEL 2
#define DEBUG
#else
#define DEBLEVEL 2
#endif
#define VERBOSE 3
// now the real includes
#define WIN32_APIS
#define UNICODE 2
#include "shdcom.h"
#include "oslayer.h"
#include "record.h"
#include "cshadow.h"
#include "utils.h"
#include "hookcmmn.h"
#include "cscsec.h"
#include "log.h"
#include "ntcsclow.h"
//we have to redefine status_pending since the win95 stuff redefines it.......
#undef STATUS_PENDING
#define STATUS_PENDING ((NTSTATUS)0x00000103L) // winnt
ULONG
IFSMgr_Get_NetTime();
#ifndef MRXSMB_BUILD_FOR_CSC_DCON
//define these to passivate so that i can share some code......
#undef mIsDisconnected
#define mIsDisconnected(pResource) (FALSE)
//#define mShadowOutofSync(uShadowStatus) (mQueryBits(uShadowStatus, SHADOW_MODFLAGS|SHADOW_ORPHAN))
#undef mShadowOutofSync
#define mShadowOutofSync(uShadowStatus) (FALSE)
#else
//dont allow mIsDisconnected anymore in common code
#undef mIsDisconnected
#define mIsDisconnected(pResource) (LALA)
#define mShadowOutofSync(uShadowStatus) (mQueryBits(uShadowStatus, SHADOW_MODFLAGS|SHADOW_ORPHAN))
#endif
#endif //ifdef __NTCSC_H__
| 24.347594 | 103 | 0.685043 |
12302271872c54ac4b928eb845c8ab3401350d34 | 1,036 | c | C | src/main.c | arcticwx/Notetakr | b010bde5668277b56cb684b7ef7081f887c4d9a5 | [
"MIT"
] | null | null | null | src/main.c | arcticwx/Notetakr | b010bde5668277b56cb684b7ef7081f887c4d9a5 | [
"MIT"
] | null | null | null | src/main.c | arcticwx/Notetakr | b010bde5668277b56cb684b7ef7081f887c4d9a5 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
// For future: GUI with SDL?
void write(char **towrite[20], char **filename[]){
FILE *file;
file = fopen(filename, "w+");
fputs(towrite, file);
fclose(file);
}
void read(char **filename){
FILE *file;
char buff[255];
file = fopen(filename, "r");
fgets(buff, 255, (FILE*)file);
printf("Contents: %s\n", buff);
fclose(file);
}
int main(void){
printf("Welcome to notetakr, what option? ");
char opt[20];
scanf("%s", opt);
/* Writing logic */
if (strcmp(opt, "write") == 0) {
printf("Option chose: Written. enter your filename: ");
char arg[20];
char name[20];
scanf("%s", &name); printf("and the note: "); scanf("%s", &arg); write(arg, name);
}
/* Reading logic */ // TODO: FIX / COMPLETE
if(strcmp(opt, "read") == 0){
printf("Option chose: Read. enter the file to read: ");
char name[20];
scanf("%s", &name);
}
return 0;
} | 22.521739 | 93 | 0.541506 |
8534de5e4af29abd6fafad1699a3708aa0a584a3 | 3,168 | c | C | lib/io/console.c | CunningLearner/lk | badbeb691a805b3f99520299fe60598a6233481f | [
"MIT"
] | 17 | 2020-02-26T22:01:49.000Z | 2022-03-04T16:48:27.000Z | lib/io/console.c | CunningLearner/lk | badbeb691a805b3f99520299fe60598a6233481f | [
"MIT"
] | null | null | null | lib/io/console.c | CunningLearner/lk | badbeb691a805b3f99520299fe60598a6233481f | [
"MIT"
] | 4 | 2020-02-22T17:14:13.000Z | 2021-03-28T17:55:19.000Z | /*
* Copyright (c) 2008-2015 Travis Geiselbrecht
*
* Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT
*/
#include <lib/io.h>
#include <lk/err.h>
#include <ctype.h>
#include <lk/debug.h>
#include <assert.h>
#include <lk/list.h>
#include <string.h>
#include <lib/cbuf.h>
#include <arch/ops.h>
#include <platform.h>
#include <platform/debug.h>
#include <kernel/thread.h>
#include <lk/init.h>
/* routines for dealing with main console io */
#if WITH_LIB_SM
#define PRINT_LOCK_FLAGS SPIN_LOCK_FLAG_IRQ_FIQ
#else
#define PRINT_LOCK_FLAGS SPIN_LOCK_FLAG_INTERRUPTS
#endif
static spin_lock_t print_spin_lock = 0;
static struct list_node print_callbacks = LIST_INITIAL_VALUE(print_callbacks);
#if CONSOLE_HAS_INPUT_BUFFER
#ifndef CONSOLE_BUF_LEN
#define CONSOLE_BUF_LEN 256
#endif
/* global input circular buffer */
cbuf_t console_input_cbuf;
static uint8_t console_cbuf_buf[CONSOLE_BUF_LEN];
#endif // CONSOLE_HAS_INPUT_BUFFER
/* print lock must be held when invoking out, outs, outc */
static void out_count(const char *str, size_t len) {
print_callback_t *cb;
size_t i;
/* print to any registered loggers */
if (!list_is_empty(&print_callbacks)) {
spin_lock_saved_state_t state;
spin_lock_save(&print_spin_lock, &state, PRINT_LOCK_FLAGS);
list_for_every_entry(&print_callbacks, cb, print_callback_t, entry) {
if (cb->print)
cb->print(cb, str, len);
}
spin_unlock_restore(&print_spin_lock, state, PRINT_LOCK_FLAGS);
}
/* write out the serial port */
for (i = 0; i < len; i++) {
platform_dputc(str[i]);
}
}
void register_print_callback(print_callback_t *cb) {
spin_lock_saved_state_t state;
spin_lock_save(&print_spin_lock, &state, PRINT_LOCK_FLAGS);
list_add_head(&print_callbacks, &cb->entry);
spin_unlock_restore(&print_spin_lock, state, PRINT_LOCK_FLAGS);
}
void unregister_print_callback(print_callback_t *cb) {
spin_lock_saved_state_t state;
spin_lock_save(&print_spin_lock, &state, PRINT_LOCK_FLAGS);
list_delete(&cb->entry);
spin_unlock_restore(&print_spin_lock, state, PRINT_LOCK_FLAGS);
}
static ssize_t __debug_stdio_write(io_handle_t *io, const char *s, size_t len) {
out_count(s, len);
return len;
}
static ssize_t __debug_stdio_read(io_handle_t *io, char *s, size_t len) {
if (len == 0)
return 0;
#if CONSOLE_HAS_INPUT_BUFFER
ssize_t err = cbuf_read(&console_input_cbuf, s, len, true);
return err;
#else
int err = platform_dgetc(s, true);
if (err < 0)
return err;
return 1;
#endif
}
#if CONSOLE_HAS_INPUT_BUFFER
void console_init_hook(uint level) {
cbuf_initialize_etc(&console_input_cbuf, sizeof(console_cbuf_buf), console_cbuf_buf);
}
LK_INIT_HOOK(console, console_init_hook, LK_INIT_LEVEL_PLATFORM_EARLY - 1);
#endif
/* global console io handle */
static const io_handle_hooks_t console_io_hooks = {
.write = __debug_stdio_write,
.read = __debug_stdio_read,
};
io_handle_t console_io = IO_HANDLE_INITIAL_VALUE(&console_io_hooks);
| 25.756098 | 89 | 0.724432 |
6ac0ab443ea079658af7c093d7e6b3f08463655e | 6,249 | h | C | Gems/GameState/Code/Source/GameStateSystemComponent.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-09-13T00:01:12.000Z | 2021-09-13T00:01:12.000Z | Gems/GameState/Code/Source/GameStateSystemComponent.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | null | null | null | Gems/GameState/Code/Source/GameStateSystemComponent.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-07-20T11:07:25.000Z | 2021-07-20T11:07:25.000Z | /*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <GameState/GameStateRequestBus.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/std/containers/deque.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace GameState
{
////////////////////////////////////////////////////////////////////////////////////////////////
//! This system component manages game state instances and the transitions between them. A few
//! default game states are implemented in the GameStateSamples Gem, and these can be extended
//! as needed in order to provide a custom experience for each game, but it's also possible to
//! create completely new states by inheriting from the abstract GameState::IGameState class.
//! States are managed using a stack (pushdown automaton) in order to maintain their history.
class GameStateSystemComponent : public AZ::Component
, public AZ::TickBus::Handler
, public GameStateRequestBus::Handler
{
public:
////////////////////////////////////////////////////////////////////////////////////////////
// AZ::Component Setup
AZ_COMPONENT(GameStateSystemComponent, "{03A10E41-3339-42C1-A6C8-A81327CB034B}");
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AZ::ComponentDescriptor::Reflect
static void Reflect(AZ::ReflectContext* context);
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AZ::ComponentDescriptor::GetProvidedServices
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AZ::ComponentDescriptor::GetIncompatibleServices
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
protected:
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AZ::Component::Activate
void Activate() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AZ::Component::Deactivate
void Deactivate() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AZ::TickEvents::GetTickOrder
int GetTickOrder() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref AZ::TickEvents::OnTick
void OnTick(float deltaTime, AZ::ScriptTimePoint scriptTimePoint) override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::UpdateActiveGameState
void UpdateActiveGameState() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::GetActiveGameState
AZStd::shared_ptr<IGameState> GetActiveGameState() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::PushGameState
bool PushGameState(AZStd::shared_ptr<IGameState> newGameState) override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::PopActiveGameState
bool PopActiveGameState() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::PopAllGameStates
void PopAllGameStates() override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::ReplaceActiveGameState
bool ReplaceActiveGameState(AZStd::shared_ptr<IGameState> newGameState) override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::DoesStackContainGameStateOfTypeId
bool DoesStackContainGameStateOfTypeId(const AZ::TypeId& gameStateTypeId) override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::AddGameStateFactoryOverrideForTypeId
bool AddGameStateFactoryOverrideForTypeId(const AZ::TypeId& gameStateTypeId,
GameStateFactory factory) override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::RemoveGameStateFactoryOverrideForTypeId
bool RemoveGameStateFactoryOverrideForTypeId(const AZ::TypeId& gameStateTypeId) override;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref GameState::GameStateRequests::GetGameStateFactoryOverrideForTypeId
GameStateFactory GetGameStateFactoryOverrideForTypeId(const AZ::TypeId& gameStateTypeId) override;
private:
////////////////////////////////////////////////////////////////////////////////////////////
//! The game state stack, where the top element is considered to be the active game state
AZStd::deque<AZStd::shared_ptr<IGameState>> m_gameStateStack;
////////////////////////////////////////////////////////////////////////////////////////////
//! A map of game state factory functions indexed by the game state type id to override
AZStd::unordered_map<AZ::TypeId, GameStateFactory> m_gameStateFactoryOverrides;
};
}
| 55.300885 | 158 | 0.457193 |
5c1ba13de65be90240d34ad165175094ff00dbf6 | 19,212 | h | C | Fbx-conv/src/readers/FbxAnimation.h | Jin02/SOCEngine | 7a04d914149783f54aecf2fbbc4e78a7325f0fbd | [
"MIT"
] | 14 | 2015-12-24T03:08:59.000Z | 2021-12-13T13:29:07.000Z | Fbx-conv/src/readers/FbxAnimation.h | Jin02/SOCEngine | 7a04d914149783f54aecf2fbbc4e78a7325f0fbd | [
"MIT"
] | 106 | 2015-08-16T10:32:47.000Z | 2018-10-08T19:01:44.000Z | Fbx-conv/src/readers/FbxAnimation.h | Jin02/SOCEngine | 7a04d914149783f54aecf2fbbc4e78a7325f0fbd | [
"MIT"
] | 2 | 2018-03-02T06:17:08.000Z | 2020-02-11T11:19:41.000Z | /*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
/** @author Xoppa */
#ifdef _MSC_VER
#pragma once
#endif //_MSC_VER
#ifndef FBXCONV_READERS_FBXANIMATION_H
#define FBXCONV_READERS_FBXANIMATION_H
#include "fbxsdk_2014_2_1.h"
#include "../Settings.h"
#include "../log/log.h"
#include "util.h"
#include "../modeldata/Model.h"
#include <map>
using namespace fbxconv::modeldata;
namespace fbxconv {
namespace readers {
class FbxAnimation {
public:
Settings *settings;
fbxconv::log::Log *log;
Model * const model;
std::map<const FbxNode *, Node *> nodeMap;
FbxAnimation(Settings *settings, fbxconv::log::Log *log, Model * const &model, std::map<const FbxNode *, Node *> const &nodeMap)
: settings(settings), log(log), model(model), nodeMap(nodeMap)
{
}
inline static const char *getInterpolationName(FbxAnimCurveDef::EInterpolationType iType) {
switch (iType) {
case FbxAnimCurveDef::eInterpolationConstant: return "constant";
case FbxAnimCurveDef::eInterpolationLinear: return "linear";
case FbxAnimCurveDef::eInterpolationCubic: return "cubic";
}
return "unknown";
}
static const unsigned short PropTranslation = 1;
static const unsigned short PropRotation = 2;
static const unsigned short PropScaling = 3;
unsigned short getPropertyType(FbxAnimStack * const &animStack, FbxProperty const &prop, FbxNode * &node) {
node = static_cast<FbxNode *>(prop.GetFbxObject());
FbxString propName = prop.GetName();
if (propName.Compare("DeformPercent") != 0)
{
if (node->LclTranslation.IsValid() && propName.Compare(node->LclTranslation.GetName()) == 0)
return PropTranslation;
if (node->LclRotation.IsValid() && propName.Compare(node->LclRotation.GetName()) == 0)
return PropRotation;
if (node->LclScaling.IsValid() && propName.Compare(node->LclScaling.GetName()) == 0)
return PropScaling;
}
log->warning(log::wSourceConvertFbxSkipPropname, animStack->GetName(), (const char *)propName);
return 0;
}
Animation *convert(FbxAnimStack * const &animStack) {
Animation *result = 0;
if (settings->forceFpsSamplesAnimations || !convertAnimation(animStack, result)) {
log->warning(log::wSourceConvertFbxFallbackAnimation, animStack->GetName());
convertAnimationBySampling(animStack, result);
}
return result;
}
inline static int indexOfNodeAnimation(Animation * const &animation, Node * const &node) {
int index = 0;
for (std::vector<NodeAnimation *>::const_iterator it = animation->nodeAnimations.begin(); it != animation->nodeAnimations.end(); ++it, ++index) {
if ((*it)->node == node)
return index;
}
return -1;
}
inline static int addNodeAnimationIfNotEmpty(Animation * const &animation, NodeAnimation * const &nodeAnimation, bool const &deleteIfEmpty) {
if (nodeAnimation) {
if ((nodeAnimation->rotate && !nodeAnimation->rotation.empty()) ||
(nodeAnimation->translate && !nodeAnimation->translation.empty()) ||
(nodeAnimation->scale && !nodeAnimation->scaling.empty())) {
animation->nodeAnimations.push_back(nodeAnimation);
return animation->nodeAnimations.size() - 1;
}
if (deleteIfEmpty)
delete nodeAnimation;
}
return -1;
}
template<int n>
void cleanupKeyframes(std::vector<Keyframe<n>> &keyframes, float *defaultValue) {
for (int i = 1; i < (keyframes.size() - 1);) {
Keyframe<n> &k1 = keyframes[i - 1];
Keyframe<n> &k2 = keyframes[i];
Keyframe<n> &k3 = keyframes[i + 1];
if (isLerp(k1.value, k1.time, k2.value, k2.time, k3.value, k3.time, n))
keyframes.erase(keyframes.begin() + i);
else
++i;
}
if ((keyframes.size() == 2) && (cmp(keyframes[0].value, keyframes[1].value, n)))
keyframes.erase(keyframes.begin() + 1);
if ((keyframes.size() == 1) && (cmp(keyframes[0].value, defaultValue, n)))
keyframes.clear();
}
bool addTranslationKeyframes(NodeAnimation * const &nodeAnimation, FbxNode *node, FbxAnimCurve * const &curve) {
assert(nodeAnimation->translation.empty());
int keyCount = curve->KeyGetCount();
for (int keyIndex = 0; keyIndex < keyCount; ++keyIndex) {
FbxTime keyTime = curve->KeyGetTime(keyIndex);
FbxVector4 localTranslation = node->EvaluateLocalTranslation(keyTime);
Keyframe<3> kf;
kf.time = (float)(1000.0 * keyTime.GetSecondDouble());
kf.value[0] = localTranslation.mData[0];
kf.value[1] = localTranslation.mData[1];
kf.value[2] = localTranslation.mData[2];
nodeAnimation->translation.push_back(kf);
}
cleanupKeyframes<3>(nodeAnimation->translation, (float*)nodeAnimation->node->transform.translation);
nodeAnimation->translate = !nodeAnimation->translation.empty();
return true;
}
bool addRotationKeyframes(NodeAnimation * const &nodeAnimation, FbxNode *node, FbxAnimCurve * const &curve) {
assert(nodeAnimation->rotation.empty());
int keyCount = curve->KeyGetCount();
for (int keyIndex = 0; keyIndex < keyCount; ++keyIndex) {
FbxTime keyTime = curve->KeyGetTime(keyIndex);
FbxAMatrix tmp;
tmp.SetR(node->EvaluateLocalRotation(keyTime));
FbxQuaternion localRotation = tmp.GetQ();
Keyframe<4> kf;
kf.time = (float)(1000.0 * keyTime.GetSecondDouble());
kf.value[0] = localRotation.mData[0];
kf.value[1] = localRotation.mData[1];
kf.value[2] = localRotation.mData[2];
kf.value[3] = localRotation.mData[3];
nodeAnimation->rotation.push_back(kf);
}
int start = nodeAnimation->rotation.size();
cleanupKeyframes<4>(nodeAnimation->rotation, (float*)nodeAnimation->node->transform.rotation);
int end = nodeAnimation->rotation.size();
if (end != start)
printf("Removed %d - %d = %d keyframes\n", start, end, start - end);
nodeAnimation->rotate = !nodeAnimation->rotation.empty();
return true;
}
/** Add the specified animation by adding the actual keyframes of components the animation consist of */
bool convertAnimation(FbxAnimStack * const &animStack, Animation * &result) {
const int layerCount = animStack->GetMemberCount<FbxAnimLayer>();
if (layerCount != 1) {
log->warning(log::wSourceConvertFbxLayeredAnimation, animStack->GetName(), layerCount);
return false;
}
bool success = true;
Animation *animation = new Animation();
animation->id = animStack->GetName();
animStack->GetScene()->SetCurrentAnimationStack(animStack);
// There should only be one layer (layers are used for blending animations)
for (int layerIndex = 0; success && layerIndex < layerCount; ++layerIndex) {
FbxAnimLayer *layer = animStack->GetMember<FbxAnimLayer>(layerIndex);
Node *node = 0;
NodeAnimation *nodeAnimation = 0;
int nodeAnimationIndex = -1;
const int curveNodeCount = layer->GetSrcObjectCount<FbxAnimCurveNode>();
// Each node affected by this animation (although the fbx design doesnt seem to restrict it to a single node, which is why the node is fetched per property)
for (int curveNodeIndex = 0; success && curveNodeIndex < curveNodeCount; ++curveNodeIndex) {
FbxAnimCurveNode *curveNode = layer->GetSrcObject<FbxAnimCurveNode>(curveNodeIndex);
const int curveCount = curveNode->GetCurveCount(0U);
if (curveCount != 1) {
log->warning(log::wSourceConvertFbxMultipleCurves, animStack->GetName(), curveCount);
success = false;
break;
}
FbxAnimCurve *curve = curveNode->GetCurve(0U);
FbxAnimCurveDef::EInterpolationType itype = curve->KeyGetInterpolation(0);
unsigned short prop;
FbxNode *fbxNode = 0;
const int propertyCount = curveNode->GetDstPropertyCount();
// Each property of this node affected (keyed) by this animation
for (int propertyIndex = 0; success && propertyIndex < propertyCount; ++propertyIndex) {
if (!(prop = getPropertyType(animStack, curveNode->GetDstProperty(propertyIndex), fbxNode)))
continue;
std::map<const FbxNode *, Node *>::iterator it = nodeMap.find(fbxNode);
if (it == nodeMap.end()) {
log->warning(log::wSourceConvertFbxUnknownNodeAnim, animStack->GetName(), fbxNode->GetName());
continue;
}
if (node != it->second) {
if (nodeAnimationIndex < 0)
addNodeAnimationIfNotEmpty(animation, nodeAnimation, true);
node = it->second;
nodeAnimationIndex = indexOfNodeAnimation(animation, node);
if (nodeAnimationIndex < 0)
(nodeAnimation = new NodeAnimation())->node = node;
else
nodeAnimation = animation->nodeAnimations.at(nodeAnimationIndex);
}
if (prop == PropTranslation)
success = success && addTranslationKeyframes(nodeAnimation, fbxNode, curve);
else if (prop == PropRotation)
success = success && addRotationKeyframes(nodeAnimation, fbxNode, curve);
//printf("Anim(%s).Layer(%s).CurveNode(%s).Node(%s).Prop(%d).Keys[%d] = %s\n", animStack->GetName(), layer->GetName(), curveNode->GetName(), node->id.c_str(), prop, keyCount, getInterpolationName(itype));
}
}
if (nodeAnimationIndex < 0)
addNodeAnimationIfNotEmpty(animation, nodeAnimation, true);
}
if (!success)
delete animation;
else if (animation->nodeAnimations.empty()) {
log->warning(log::wSourceConvertFbxSkipAnimation, animation->id.c_str());
delete animation;
}
else
result = animation;
return success;
}
////////////////////////////////////////////////////////////////
//// OLDER (v0.1) SAMPLING BASED ANIMATIONS BELOW THIS LINE ////
////////////////////////////////////////////////////////////////
/** Add the specified animation to the model by samples the affected nodes transforms for each keyframe */
void convertAnimationBySampling(FbxAnimStack * const &animStack, Animation * &animation) {
static std::vector<Keyframe<3>> translationKeyFrames;
static std::vector<Keyframe<4>> rotationKeyFrames;
static std::vector<Keyframe<3>> scalingKeyFrames;
static std::map<FbxNode *, AnimInfo> affectedNodes;
affectedNodes.clear();
FbxTimeSpan animTimeSpan = animStack->GetLocalTimeSpan();
float animStart = (float)(animTimeSpan.GetStart().GetMilliSeconds());
float animStop = (float)(animTimeSpan.GetStop().GetMilliSeconds());
if (animStop <= animStart)
animStop = 999999999.0f;
// Could also use animStack->GetLocalTimeSpan and animStack->BakeLayers, but its not guaranteed to be correct
const int layerCount = animStack->GetMemberCount<FbxAnimLayer>();
for (int l = 0; l < layerCount; l++) {
FbxAnimLayer *layer = animStack->GetMember<FbxAnimLayer>(l);
// For each layer check which node is affected and within what time frame and rate
const int curveNodeCount = layer->GetSrcObjectCount<FbxAnimCurveNode>();
for (int n = 0; n < curveNodeCount; n++) {
FbxAnimCurveNode *curveNode = layer->GetSrcObject<FbxAnimCurveNode>(n);
// Check which properties on this curve are changed
const int nc = curveNode->GetDstPropertyCount();
for (int o = 0; o < nc; o++) {
FbxProperty prop = curveNode->GetDstProperty(o);
FbxNode *node = static_cast<FbxNode *>(prop.GetFbxObject());
if (node) {
FbxString propName = prop.GetName();
if (propName == "DeformPercent")
{
// When using this propName in model an unhandled exception is launched in sentence node->LclTranslation.GetName()
log->warning(log::wSourceConvertFbxSkipPropname, animStack->GetName(), (const char *)propName);
continue;
}
// Only add translation, scaling or rotation
if ((!node->LclTranslation.IsValid() || propName != node->LclTranslation.GetName()) &&
(!node->LclScaling.IsValid() || propName != node->LclScaling.GetName()) &&
(!node->LclRotation.IsValid() || propName != node->LclRotation.GetName()))
continue;
FbxAnimCurve *curve;
AnimInfo ts;
ts.translate = propName == node->LclTranslation.GetName();
ts.rotate = propName == node->LclRotation.GetName();
ts.scale = propName == node->LclScaling.GetName();
if (curve = prop.GetCurve(layer, FBXSDK_CURVENODE_COMPONENT_X))
updateAnimTime(curve, ts, animStart, animStop);
if (curve = prop.GetCurve(layer, FBXSDK_CURVENODE_COMPONENT_Y))
updateAnimTime(curve, ts, animStart, animStop);
if (curve = prop.GetCurve(layer, FBXSDK_CURVENODE_COMPONENT_Z))
updateAnimTime(curve, ts, animStart, animStop);
//if (ts.start < ts.stop)
affectedNodes[node] += ts;
}
}
}
}
if (affectedNodes.empty())
return;
animation = new Animation();
animation->id = animStack->GetName();
animStack->GetScene()->SetCurrentAnimationStack(animStack);
// Add the NodeAnimations to the Animation
for (std::map<FbxNode *, AnimInfo>::const_iterator itr = affectedNodes.begin(); itr != affectedNodes.end(); itr++) {
Node *node = model->getNode((*itr).first->GetName());
if (!node)
continue;
translationKeyFrames.clear();
rotationKeyFrames.clear();
scalingKeyFrames.clear();
NodeAnimation *nodeAnim = new NodeAnimation();
nodeAnim->node = node;
nodeAnim->translate = (*itr).second.translate;
nodeAnim->rotate = (*itr).second.rotate;
nodeAnim->scale = (*itr).second.scale;
const float stepSize = (*itr).second.framerate <= 0.f ? (*itr).second.stop - (*itr).second.start : 1000.f / (*itr).second.framerate;
const float last = (*itr).second.stop + stepSize * 0.5f;
FbxTime fbxTime;
// Calculate all keyframes upfront
for (float time = (*itr).second.start; time <= last; time += stepSize) {
time = std::min(time, (*itr).second.stop);
fbxTime.SetMilliSeconds((FbxLongLong)time);
Keyframe<3> kfT;
Keyframe<4> kfR;
Keyframe<3> kfS;
kfT.time = (time - animStart);
kfR.time = (time - animStart);
kfS.time = (time - animStart);
FbxAMatrix *m = &(*itr).first->EvaluateLocalTransform(fbxTime);
FbxVector4 v = m->GetT();
kfT.value[0] = (float)v.mData[0];
kfT.value[1] = (float)v.mData[1];
kfT.value[2] = (float)v.mData[2];
FbxQuaternion q = m->GetQ();
kfR.value[0] = (float)q.mData[0];
kfR.value[1] = (float)q.mData[1];
kfR.value[2] = (float)q.mData[2];
kfR.value[3] = (float)q.mData[3];
v = m->GetS();
kfS.value[0] = (float)v.mData[0];
kfS.value[1] = (float)v.mData[1];
kfS.value[2] = (float)v.mData[2];
translationKeyFrames.push_back(kfT);
rotationKeyFrames.push_back(kfR);
scalingKeyFrames.push_back(kfS);
}
// Only add keyframes really needed
addKeyframes(nodeAnim, translationKeyFrames, rotationKeyFrames, scalingKeyFrames);
if (nodeAnim->rotate || nodeAnim->scale || nodeAnim->translate)
animation->nodeAnimations.push_back(nodeAnim);
else
delete nodeAnim;
}
}
inline void updateAnimTime(FbxAnimCurve *const &curve, AnimInfo &ts, const float &animStart, const float &animStop) {
FbxTimeSpan fts;
curve->GetTimeInterval(fts);
const FbxTime start = fts.GetStart();
const FbxTime stop = fts.GetStop();
ts.start = std::max(animStart, std::min(ts.start, (float)(start.GetMilliSeconds())));
ts.stop = std::min(animStop, std::max(ts.stop, (float)stop.GetMilliSeconds()));
// Could check the number and type of keys (ie curve->KeyGetInterpolation) to lower the framerate
ts.framerate = std::max(ts.framerate, (float)stop.GetFrameRate(FbxTime::eDefaultMode));
}
void addKeyframes(NodeAnimation *const &anim, std::vector<Keyframe<3>> &translationKeyFrames, std::vector<Keyframe<4>> &rotationKeyFrames, std::vector<Keyframe<3>> &scalingKeyFrames) {
bool translate = false, rotate = false, scale = false;
// Check which components are actually changed
for (std::vector<Keyframe<3>>::const_iterator itr = translationKeyFrames.begin(); itr != translationKeyFrames.end(); ++itr) {
if (!translate && !cmp(anim->node->transform.translation, itr->value, 3))
translate = true;
}
for (std::vector<Keyframe<4>>::const_iterator itr = rotationKeyFrames.begin(); itr != rotationKeyFrames.end(); ++itr) {
if (!rotate && !cmp(anim->node->transform.rotation, itr->value, 4))
rotate = true;
}
for (std::vector<Keyframe<3>>::const_iterator itr = scalingKeyFrames.begin(); itr != scalingKeyFrames.end(); ++itr) {
if (!scale && !cmp(anim->node->transform.scale, itr->value, 3))
scale = true;
}
// This allows to only export the values actual needed
anim->translate = translate;
anim->rotate = rotate;
anim->scale = scale;
if (translate && !translationKeyFrames.empty()) {
anim->translation.push_back(translationKeyFrames[0]);
const int last = (int)translationKeyFrames.size() - 1;
Keyframe<3> k1 = translationKeyFrames[0], k2, k3;
for (int i = 1; i < last; i++) {
k2 = translationKeyFrames[i];
k3 = translationKeyFrames[i + 1];
// Check if the middle keyframe can be calculated by information, if so dont add it
if (translate && !isLerp(k1.value, k1.time, k2.value, k2.time, k3.value, k3.time, 3)) {
anim->translation.push_back(k2);
k1 = k2;
}
}
if (last > 0)
anim->translation.push_back(translationKeyFrames[last]);
}
if (rotate && !rotationKeyFrames.empty()) {
anim->rotation.push_back(rotationKeyFrames[0]);
const int last = (int)rotationKeyFrames.size() - 1;
Keyframe<4> k1 = rotationKeyFrames[0], k2, k3;
for (int i = 1; i < last; i++) {
k2 = rotationKeyFrames[i];
k3 = rotationKeyFrames[i + 1];
// Check if the middle keyframe can be calculated by information, if so dont add it
if (rotate && !isLerp(k1.value, k1.time, k2.value, k2.time, k3.value, k3.time, 4)) {
anim->rotation.push_back(k2);
k1 = k2;
}
}
if (last > 0)
anim->rotation.push_back(rotationKeyFrames[last]);
}
if (scale && !scalingKeyFrames.empty()) {
anim->scaling.push_back(scalingKeyFrames[0]);
const int last = (int)scalingKeyFrames.size() - 1;
Keyframe<3> k1 = scalingKeyFrames[0], k2, k3;
for (int i = 1; i < last; i++) {
k2 = scalingKeyFrames[i];
k3 = scalingKeyFrames[i + 1];
// Check if the middle keyframe can be calculated by information, if so dont add it
if (scale && !isLerp(k1.value, k1.time, k2.value, k2.time, k3.value, k3.time, 3)) {
anim->scaling.push_back(k2);
k1 = k2;
}
}
if (last > 0)
anim->scaling.push_back(scalingKeyFrames[last]);
}
}
};
} }
#endif //FBXCONV_READERS_FBXANIMATION_H | 41.856209 | 210 | 0.666667 |
4be56c9d85d7d420d127058ba04c6fb1400c0df3 | 1,234 | h | C | src/SLAM/VisualOdometry/DeviceSpecific/OpenCL/NuiKinfuOpenCLFeedbackFrame.h | hustztz/NatureUserInterfaceStudio | 3cdac6b6ee850c5c8470fa5f1554c7447be0d8af | [
"MIT"
] | 3 | 2016-07-14T13:04:35.000Z | 2017-04-01T09:58:27.000Z | src/SLAM/VisualOdometry/DeviceSpecific/OpenCL/NuiKinfuOpenCLFeedbackFrame.h | hustztz/NatureUserInterfaceStudio | 3cdac6b6ee850c5c8470fa5f1554c7447be0d8af | [
"MIT"
] | null | null | null | src/SLAM/VisualOdometry/DeviceSpecific/OpenCL/NuiKinfuOpenCLFeedbackFrame.h | hustztz/NatureUserInterfaceStudio | 3cdac6b6ee850c5c8470fa5f1554c7447be0d8af | [
"MIT"
] | 1 | 2021-11-21T15:33:35.000Z | 2021-11-21T15:33:35.000Z | #pragma once
#include "../NuiKinfuFeedbackFrame.h"
#include "OpenCLUtilities/NuiOpenCLUtil.h"
class NuiKinfuOpenCLFeedbackFrame : public NuiKinfuFeedbackFrame
{
public:
NuiKinfuOpenCLFeedbackFrame(UINT nWidth, UINT nHeight);
virtual ~NuiKinfuOpenCLFeedbackFrame();
virtual void UpdateBuffers(NuiKinfuFrame* pFrame, NuiKinfuCameraState* pCameraState) override;
virtual UINT GetWidth() const override { return m_nWidth; }
virtual UINT GetHeight() const override { return m_nHeight; }
virtual bool VerticesToMappablePosition(NuiCLMappableData* pMappableData) override;
virtual bool BufferToMappableTexture(NuiCLMappableData* pMappableData, TrackerBufferType bufferType) override;
cl_mem GetVertexBuffer() const { return m_verticesCL; }
cl_mem GetNormalBuffer() const { return m_normalsCL; }
cl_mem GetColorBuffer() const { return m_colorsCL; }
protected:
void AcquireBuffers(UINT nWidth, UINT nHeight);
void ReleaseBuffers();
void Vertex2Normal(cl_mem verticesCL, float depth_threshold);
void TransformBuffers(cl_mem verticesCL, cl_mem normalsCL, cl_mem transformCL);
void CopyColors(cl_mem colorsCL);
protected:
UINT m_nWidth, m_nHeight;
private:
cl_mem m_verticesCL;
cl_mem m_normalsCL;
cl_mem m_colorsCL;
}; | 33.351351 | 111 | 0.812804 |
ef667bceda0560677daf732edbc72987c7ff917e | 3,429 | c | C | student-distrib/initpaging.c | JackYupeng/Small-Linux-OS | ca40a9947a9c1db68138c79d94edee95c3368bde | [
"AFL-1.1"
] | null | null | null | student-distrib/initpaging.c | JackYupeng/Small-Linux-OS | ca40a9947a9c1db68138c79d94edee95c3368bde | [
"AFL-1.1"
] | null | null | null | student-distrib/initpaging.c | JackYupeng/Small-Linux-OS | ca40a9947a9c1db68138c79d94edee95c3368bde | [
"AFL-1.1"
] | null | null | null | #include "initpaging.h"
#include "x86_desc.h"
#include "lib.h"
static unsigned long kernel = ker_add;// the kernel address
static uint32_t page_directory[page_size] __attribute__((aligned(size_direc)));
static uint32_t first_page_table[page_size] __attribute__((aligned(size_direc)));
/*
* paging_initialize()
* DESCRIPTION: initialize the paging ,setting the page_directory and page_table
* find the location of video meomery and then save it.
* INPUTS: none(ignored)
* OUTPUTS: none
* RETURN VALUE: none
* SIDE EFFECTS: none
*/
//cited from http://wiki.osdev.org/Setting_Up_Paging
void paging_initialize()
{
//set each entry to not present
int i;
for(i = 0; i < page_size; i++)
{
//first set all the entry to 0x00000002 mean that
//it is not present but can write and read
page_directory[i] = nopresent_rw;
}
unsigned int vm_index; //where the videomemory should be save in page_table;
vm_index = videomemory >> bitmask ;
//we will fill all 1024 entries in the table, mapping 4 megabytes
for(i = 0; i < page_size; i++)
{
//get the index of videomemory and locate the address of videomemory.
//search every page_table_index until the vm_index
if(i == vm_index)
{
//save the vm_index and set the u/s r/w and p to 1.
first_page_table[i] = videomemory | present_rw;
}
else
{
first_page_table[i] = (i * page_add) | no_rw;
}
}
// attributes: supervisor level, read/write, present
//reference from: Osdev/setting_paging.
page_directory[0] = ((unsigned int)first_page_table) | present_rw;
page_directory[1] = kernel | kern;
//call the the function in initpaging.S
//to store the cr3 and cr0;
loadPageDirectory(page_directory);
enablePaging();
return;
}
/*
*map_to_user_phy(uint32_t program_number,uint32_t start_address,uint32_t program_size)
* DESCRIPTION: map to paging depending ong the program_number
* INPUTS: uint32_t program_number,uint32_t start_address,uint32_t program_size
* OUTPUTS: none
* RETURN VALUE: none
* SIDE EFFECTS: none
*/
void map_to_user_phy(uint32_t program_number,uint32_t start_address,uint32_t program_size)
{
uint32_t cur_address;
uint32_t pde_index;
pde_index = B_128 / 4 ;
cur_address = (program_number+2) * program_size;
page_directory[pde_index] = cur_address | all_o ;
tlb_flush();
return;
}
/*
* map_to_vid(uint32_t virtual_address, uint32_t phy_address)
* DESCRIPTION: map to video meomry
* INPUTS: uint32_t virtual_address, uint32_t phy_address
* OUTPUTS: none
* RETURN VALUE: none
* SIDE EFFECTS: none
*/
void map_to_vid(uint32_t virtual_address, uint32_t phy_address)
{
uint32_t pde_index = (B_128+4) / 4 ;
page_directory[pde_index]=(uint32_t)first_page_table |read_write;
first_page_table[0] = phy_address|read_write;
}
void vur_phy(uint32_t phy, uint32_t vir)
{
uint32_t pde_index = vir / 0x400000;
page_directory[pde_index] = phy | all_o;
}
void teminial_map_pages(uint32_t terminal_id)
{
unsigned int vm_index;
unsigned int vm;
vm = videomemory + terminal_id*0x1000;
vm_index = vm >>bitmask;
first_page_table[vm_index] = vm | present_rw;
}
/*
* tlb_flush(void)
* DESCRIPTION: flush tlb
* INPUTS: none
* OUTPUTS: none
* RETURN VALUE: none
* SIDE EFFECTS: none
*/
//referenced from osdev_flush.
void tlb_flush(void)
{
asm volatile(
"movl %%cr3,%%eax;"
"movl %%eax,%%cr3;"
:
:
:"%eax"
);
}
| 22.708609 | 90 | 0.715369 |
d45221b0bc75ec9f4d7160265fb4083297a50e0f | 575 | h | C | include/joy/array/to_tree.h | ldionne/joy | ce24d7a2b2b0524d4645c77588cddc6c1d241368 | [
"MIT"
] | 5 | 2015-11-25T12:56:46.000Z | 2019-06-28T12:08:49.000Z | include/joy/array/to_tree.h | ldionne/joy | ce24d7a2b2b0524d4645c77588cddc6c1d241368 | [
"MIT"
] | null | null | null | include/joy/array/to_tree.h | ldionne/joy | ce24d7a2b2b0524d4645c77588cddc6c1d241368 | [
"MIT"
] | null | null | null | /*!
* This file defines a macro to transform an array into a tree.
*
* @author Louis Dionne
*/
#ifndef JOY_ARRAY_TO_TREE_H
#define JOY_ARRAY_TO_TREE_H
#include <joy/seq/to_tree.h>
#include <chaos/preprocessor/recursion/expr.h>
#include <chaos/preprocessor/array/to_seq.h>
/*!
* Transform an array into a tree.
*/
#define JOY_ARRAY_TO_TREE(compare, array) \
JOY_ARRAY_TO_TREE_S(CHAOS_PP_STATE(), compare, array)
#define JOY_ARRAY_TO_TREE_S(s, compare, array) \
JOY_SEQ_TO_TREE_S(s, compare, CHAOS_PP_ARRAY_TO_SEQ(array))
#endif /* !JOY_ARRAY_TO_TREE_H */
| 22.115385 | 63 | 0.744348 |
d47121eb43ef1fdfad9d9bbb13f7805f2fa3f42d | 1,783 | c | C | lib/wizards/tiergon/dungeon/monsters/bclord.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/tiergon/dungeon/monsters/bclord.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/tiergon/dungeon/monsters/bclord.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | inherit "obj/monster";
int number_of_fighters;
object armour,sword;
reset(arg) {
::reset(arg);
number_of_fighters = 0;
if(arg) { return; }
set_level(57);
set_name("commander");
set_short("The Commander of the Black Circle ");
set_long("The commander of the legendary mercenary group is a truly imposing individual. His black plate armor is matched by his dark hair and ice-blue eyes. It is easy to see how he has risen to this position, as an aura of power surrounds him like a dark halo.\n");
set_al(-160);
set_extra(1);
set_log();
set_gender(1);
set_race("human");
set_aggressive(1);
armour = clone_object("/wizards/tiergon/eq/bclplate");
move_object(armour, this_object());
init_command("wear armour");
sword = clone_object("/wizards/tiergon/eq/bclsword");
move_object(sword, this_object());
init_command("wield sword");
}
extra() {
object fighter;
int i;
if (!attacker_ob) {
return;
}
if(!query_spell() && !this_object()->query_stunned()) {
if(random(number_of_fighters + 1) >= number_of_fighters) {
i = random(5);
if (i <= 1) {
fighter = clone_object("/wizards/tiergon/dungeon/bcamazonian3");
}
if (i == 2) {
fighter = clone_object("/wizards/tiergon/dungeon/bcfighter3");
}
if (i == 3) {
fighter = clone_object("/wizards/tiergon/dungeon/bcpriest3");
}
if (i == 4) {
fighter = clone_object("/wizards/tiergon/dungeon/bcmage");
}
move_object(fighter, environment(this_object()));
say("The Commander summons reinforcements!");
number_of_fighters += 1;
}
}
}
reduce_number() {
number_of_fighters -= 1;
}
| 29.716667 | 271 | 0.613012 |
35227f1ee3560d757e8c20bb0b5f72c9b7c73043 | 271 | h | C | Draw.h | Jin02/Mole | faf3ad0059a41c77dedca8b4a6bd004d7077cc9b | [
"MIT"
] | 1 | 2018-02-01T06:53:35.000Z | 2018-02-01T06:53:35.000Z | Draw.h | Jin02/Mole | faf3ad0059a41c77dedca8b4a6bd004d7077cc9b | [
"MIT"
] | null | null | null | Draw.h | Jin02/Mole | faf3ad0059a41c77dedca8b4a6bd004d7077cc9b | [
"MIT"
] | null | null | null | #ifndef __DRAW_H__
#define __DRAW_H__
void String(M_Char * str, M_Int32 x, M_Int32 y);
void FillRect(M_Int32 x, M_Int32 y, M_Int32 w, M_Int32 h);
void DrawImage(M_Int32 x, M_Int32 y, M_Int32 w, M_Int32 h,MC_GrpImage img,M_Int32 ImageX,M_Int32 ImageY);
#endif | 27.1 | 106 | 0.741697 |
98401090aeecd6fbcadb06ad05dbad6eef17ad3f | 49,334 | h | C | modules/danlin_fontawesome/src/Icons.h | benediktsailer/danlin_modules | f688951aecb583a339a3709313bea67423c4366e | [
"MIT"
] | 11 | 2015-08-20T11:26:36.000Z | 2022-02-13T23:17:57.000Z | modules/danlin_fontawesome/src/Icons.h | benediktsailer/danlin_modules | f688951aecb583a339a3709313bea67423c4366e | [
"MIT"
] | 7 | 2015-06-20T21:13:37.000Z | 2020-01-08T01:23:35.000Z | modules/danlin_fontawesome/src/Icons.h | benediktsailer/danlin_modules | f688951aecb583a339a3709313bea67423c4366e | [
"MIT"
] | 8 | 2017-03-01T09:22:09.000Z | 2022-02-13T23:16:58.000Z | // IMPORTANT! This file is auto-generated see extras/AwesomeMaker
#ifndef __FONTAWESOME_ICONS_H__
#define __FONTAWESOME_ICONS_H__
typedef juce::String Icon;
const Icon FontAwesome_Glass = Icon::fromUTF8(u8"\uf000");
const Icon FontAwesome_Music = Icon::fromUTF8(u8"\uf001");
const Icon FontAwesome_Search = Icon::fromUTF8(u8"\uf002");
const Icon FontAwesome_EnvelopeO = Icon::fromUTF8(u8"\uf003");
const Icon FontAwesome_Heart = Icon::fromUTF8(u8"\uf004");
const Icon FontAwesome_Star = Icon::fromUTF8(u8"\uf005");
const Icon FontAwesome_StarO = Icon::fromUTF8(u8"\uf006");
const Icon FontAwesome_User = Icon::fromUTF8(u8"\uf007");
const Icon FontAwesome_Film = Icon::fromUTF8(u8"\uf008");
const Icon FontAwesome_ThLarge = Icon::fromUTF8(u8"\uf009");
const Icon FontAwesome_Th = Icon::fromUTF8(u8"\uf00a");
const Icon FontAwesome_ThList = Icon::fromUTF8(u8"\uf00b");
const Icon FontAwesome_Check = Icon::fromUTF8(u8"\uf00c");
const Icon FontAwesome_Remove = Icon::fromUTF8(u8"\uf00d");
const Icon FontAwesome_Close = Icon::fromUTF8(u8"\uf00d");
const Icon FontAwesome_Times = Icon::fromUTF8(u8"\uf00d");
const Icon FontAwesome_SearchPlus = Icon::fromUTF8(u8"\uf00e");
const Icon FontAwesome_SearchMinus = Icon::fromUTF8(u8"\uf010");
const Icon FontAwesome_PowerOff = Icon::fromUTF8(u8"\uf011");
const Icon FontAwesome_Signal = Icon::fromUTF8(u8"\uf012");
const Icon FontAwesome_Gear = Icon::fromUTF8(u8"\uf013");
const Icon FontAwesome_Cog = Icon::fromUTF8(u8"\uf013");
const Icon FontAwesome_TrashO = Icon::fromUTF8(u8"\uf014");
const Icon FontAwesome_Home = Icon::fromUTF8(u8"\uf015");
const Icon FontAwesome_FileO = Icon::fromUTF8(u8"\uf016");
const Icon FontAwesome_ClockO = Icon::fromUTF8(u8"\uf017");
const Icon FontAwesome_Road = Icon::fromUTF8(u8"\uf018");
const Icon FontAwesome_Download = Icon::fromUTF8(u8"\uf019");
const Icon FontAwesome_ArrowCircleODown = Icon::fromUTF8(u8"\uf01a");
const Icon FontAwesome_ArrowCircleOUp = Icon::fromUTF8(u8"\uf01b");
const Icon FontAwesome_Inbox = Icon::fromUTF8(u8"\uf01c");
const Icon FontAwesome_PlayCircleO = Icon::fromUTF8(u8"\uf01d");
const Icon FontAwesome_RotateRight = Icon::fromUTF8(u8"\uf01e");
const Icon FontAwesome_Repeat = Icon::fromUTF8(u8"\uf01e");
const Icon FontAwesome_Refresh = Icon::fromUTF8(u8"\uf021");
const Icon FontAwesome_ListAlt = Icon::fromUTF8(u8"\uf022");
const Icon FontAwesome_Lock = Icon::fromUTF8(u8"\uf023");
const Icon FontAwesome_Flag = Icon::fromUTF8(u8"\uf024");
const Icon FontAwesome_Headphones = Icon::fromUTF8(u8"\uf025");
const Icon FontAwesome_VolumeOff = Icon::fromUTF8(u8"\uf026");
const Icon FontAwesome_VolumeDown = Icon::fromUTF8(u8"\uf027");
const Icon FontAwesome_VolumeUp = Icon::fromUTF8(u8"\uf028");
const Icon FontAwesome_Qrcode = Icon::fromUTF8(u8"\uf029");
const Icon FontAwesome_Barcode = Icon::fromUTF8(u8"\uf02a");
const Icon FontAwesome_Tag = Icon::fromUTF8(u8"\uf02b");
const Icon FontAwesome_Tags = Icon::fromUTF8(u8"\uf02c");
const Icon FontAwesome_Book = Icon::fromUTF8(u8"\uf02d");
const Icon FontAwesome_Bookmark = Icon::fromUTF8(u8"\uf02e");
const Icon FontAwesome_Print = Icon::fromUTF8(u8"\uf02f");
const Icon FontAwesome_Camera = Icon::fromUTF8(u8"\uf030");
const Icon FontAwesome_Font = Icon::fromUTF8(u8"\uf031");
const Icon FontAwesome_Bold = Icon::fromUTF8(u8"\uf032");
const Icon FontAwesome_Italic = Icon::fromUTF8(u8"\uf033");
const Icon FontAwesome_TextHeight = Icon::fromUTF8(u8"\uf034");
const Icon FontAwesome_TextWidth = Icon::fromUTF8(u8"\uf035");
const Icon FontAwesome_AlignLeft = Icon::fromUTF8(u8"\uf036");
const Icon FontAwesome_AlignCenter = Icon::fromUTF8(u8"\uf037");
const Icon FontAwesome_AlignRight = Icon::fromUTF8(u8"\uf038");
const Icon FontAwesome_AlignJustify = Icon::fromUTF8(u8"\uf039");
const Icon FontAwesome_List = Icon::fromUTF8(u8"\uf03a");
const Icon FontAwesome_Dedent = Icon::fromUTF8(u8"\uf03b");
const Icon FontAwesome_Outdent = Icon::fromUTF8(u8"\uf03b");
const Icon FontAwesome_Indent = Icon::fromUTF8(u8"\uf03c");
const Icon FontAwesome_VideoCamera = Icon::fromUTF8(u8"\uf03d");
const Icon FontAwesome_Photo = Icon::fromUTF8(u8"\uf03e");
const Icon FontAwesome_Image = Icon::fromUTF8(u8"\uf03e");
const Icon FontAwesome_PictureO = Icon::fromUTF8(u8"\uf03e");
const Icon FontAwesome_Pencil = Icon::fromUTF8(u8"\uf040");
const Icon FontAwesome_MapMarker = Icon::fromUTF8(u8"\uf041");
const Icon FontAwesome_Adjust = Icon::fromUTF8(u8"\uf042");
const Icon FontAwesome_Tint = Icon::fromUTF8(u8"\uf043");
const Icon FontAwesome_Edit = Icon::fromUTF8(u8"\uf044");
const Icon FontAwesome_PencilSquareO = Icon::fromUTF8(u8"\uf044");
const Icon FontAwesome_ShareSquareO = Icon::fromUTF8(u8"\uf045");
const Icon FontAwesome_CheckSquareO = Icon::fromUTF8(u8"\uf046");
const Icon FontAwesome_Arrows = Icon::fromUTF8(u8"\uf047");
const Icon FontAwesome_StepBackward = Icon::fromUTF8(u8"\uf048");
const Icon FontAwesome_FastBackward = Icon::fromUTF8(u8"\uf049");
const Icon FontAwesome_Backward = Icon::fromUTF8(u8"\uf04a");
const Icon FontAwesome_Play = Icon::fromUTF8(u8"\uf04b");
const Icon FontAwesome_Pause = Icon::fromUTF8(u8"\uf04c");
const Icon FontAwesome_Stop = Icon::fromUTF8(u8"\uf04d");
const Icon FontAwesome_Forward = Icon::fromUTF8(u8"\uf04e");
const Icon FontAwesome_FastForward = Icon::fromUTF8(u8"\uf050");
const Icon FontAwesome_StepForward = Icon::fromUTF8(u8"\uf051");
const Icon FontAwesome_Eject = Icon::fromUTF8(u8"\uf052");
const Icon FontAwesome_ChevronLeft = Icon::fromUTF8(u8"\uf053");
const Icon FontAwesome_ChevronRight = Icon::fromUTF8(u8"\uf054");
const Icon FontAwesome_PlusCircle = Icon::fromUTF8(u8"\uf055");
const Icon FontAwesome_MinusCircle = Icon::fromUTF8(u8"\uf056");
const Icon FontAwesome_TimesCircle = Icon::fromUTF8(u8"\uf057");
const Icon FontAwesome_CheckCircle = Icon::fromUTF8(u8"\uf058");
const Icon FontAwesome_QuestionCircle = Icon::fromUTF8(u8"\uf059");
const Icon FontAwesome_InfoCircle = Icon::fromUTF8(u8"\uf05a");
const Icon FontAwesome_Crosshairs = Icon::fromUTF8(u8"\uf05b");
const Icon FontAwesome_TimesCircleO = Icon::fromUTF8(u8"\uf05c");
const Icon FontAwesome_CheckCircleO = Icon::fromUTF8(u8"\uf05d");
const Icon FontAwesome_Ban = Icon::fromUTF8(u8"\uf05e");
const Icon FontAwesome_ArrowLeft = Icon::fromUTF8(u8"\uf060");
const Icon FontAwesome_ArrowRight = Icon::fromUTF8(u8"\uf061");
const Icon FontAwesome_ArrowUp = Icon::fromUTF8(u8"\uf062");
const Icon FontAwesome_ArrowDown = Icon::fromUTF8(u8"\uf063");
const Icon FontAwesome_MailForward = Icon::fromUTF8(u8"\uf064");
const Icon FontAwesome_Share = Icon::fromUTF8(u8"\uf064");
const Icon FontAwesome_Expand = Icon::fromUTF8(u8"\uf065");
const Icon FontAwesome_Compress = Icon::fromUTF8(u8"\uf066");
const Icon FontAwesome_Plus = Icon::fromUTF8(u8"\uf067");
const Icon FontAwesome_Minus = Icon::fromUTF8(u8"\uf068");
const Icon FontAwesome_Asterisk = Icon::fromUTF8(u8"\uf069");
const Icon FontAwesome_ExclamationCircle = Icon::fromUTF8(u8"\uf06a");
const Icon FontAwesome_Gift = Icon::fromUTF8(u8"\uf06b");
const Icon FontAwesome_Leaf = Icon::fromUTF8(u8"\uf06c");
const Icon FontAwesome_Fire = Icon::fromUTF8(u8"\uf06d");
const Icon FontAwesome_Eye = Icon::fromUTF8(u8"\uf06e");
const Icon FontAwesome_EyeSlash = Icon::fromUTF8(u8"\uf070");
const Icon FontAwesome_Warning = Icon::fromUTF8(u8"\uf071");
const Icon FontAwesome_ExclamationTriangle = Icon::fromUTF8(u8"\uf071");
const Icon FontAwesome_Plane = Icon::fromUTF8(u8"\uf072");
const Icon FontAwesome_Calendar = Icon::fromUTF8(u8"\uf073");
const Icon FontAwesome_Random = Icon::fromUTF8(u8"\uf074");
const Icon FontAwesome_Comment = Icon::fromUTF8(u8"\uf075");
const Icon FontAwesome_Magnet = Icon::fromUTF8(u8"\uf076");
const Icon FontAwesome_ChevronUp = Icon::fromUTF8(u8"\uf077");
const Icon FontAwesome_ChevronDown = Icon::fromUTF8(u8"\uf078");
const Icon FontAwesome_Retweet = Icon::fromUTF8(u8"\uf079");
const Icon FontAwesome_ShoppingCart = Icon::fromUTF8(u8"\uf07a");
const Icon FontAwesome_Folder = Icon::fromUTF8(u8"\uf07b");
const Icon FontAwesome_FolderOpen = Icon::fromUTF8(u8"\uf07c");
const Icon FontAwesome_ArrowsV = Icon::fromUTF8(u8"\uf07d");
const Icon FontAwesome_ArrowsH = Icon::fromUTF8(u8"\uf07e");
const Icon FontAwesome_BarChartO = Icon::fromUTF8(u8"\uf080");
const Icon FontAwesome_BarChart = Icon::fromUTF8(u8"\uf080");
const Icon FontAwesome_TwitterSquare = Icon::fromUTF8(u8"\uf081");
const Icon FontAwesome_FacebookSquare = Icon::fromUTF8(u8"\uf082");
const Icon FontAwesome_CameraRetro = Icon::fromUTF8(u8"\uf083");
const Icon FontAwesome_Key = Icon::fromUTF8(u8"\uf084");
const Icon FontAwesome_Gears = Icon::fromUTF8(u8"\uf085");
const Icon FontAwesome_Cogs = Icon::fromUTF8(u8"\uf085");
const Icon FontAwesome_Comments = Icon::fromUTF8(u8"\uf086");
const Icon FontAwesome_ThumbsOUp = Icon::fromUTF8(u8"\uf087");
const Icon FontAwesome_ThumbsODown = Icon::fromUTF8(u8"\uf088");
const Icon FontAwesome_StarHalf = Icon::fromUTF8(u8"\uf089");
const Icon FontAwesome_HeartO = Icon::fromUTF8(u8"\uf08a");
const Icon FontAwesome_SignOut = Icon::fromUTF8(u8"\uf08b");
const Icon FontAwesome_LinkedinSquare = Icon::fromUTF8(u8"\uf08c");
const Icon FontAwesome_ThumbTack = Icon::fromUTF8(u8"\uf08d");
const Icon FontAwesome_ExternalLink = Icon::fromUTF8(u8"\uf08e");
const Icon FontAwesome_SignIn = Icon::fromUTF8(u8"\uf090");
const Icon FontAwesome_Trophy = Icon::fromUTF8(u8"\uf091");
const Icon FontAwesome_GithubSquare = Icon::fromUTF8(u8"\uf092");
const Icon FontAwesome_Upload = Icon::fromUTF8(u8"\uf093");
const Icon FontAwesome_LemonO = Icon::fromUTF8(u8"\uf094");
const Icon FontAwesome_Phone = Icon::fromUTF8(u8"\uf095");
const Icon FontAwesome_SquareO = Icon::fromUTF8(u8"\uf096");
const Icon FontAwesome_BookmarkO = Icon::fromUTF8(u8"\uf097");
const Icon FontAwesome_PhoneSquare = Icon::fromUTF8(u8"\uf098");
const Icon FontAwesome_Twitter = Icon::fromUTF8(u8"\uf099");
const Icon FontAwesome_FacebookF = Icon::fromUTF8(u8"\uf09a");
const Icon FontAwesome_Facebook = Icon::fromUTF8(u8"\uf09a");
const Icon FontAwesome_Github = Icon::fromUTF8(u8"\uf09b");
const Icon FontAwesome_Unlock = Icon::fromUTF8(u8"\uf09c");
const Icon FontAwesome_CreditCard = Icon::fromUTF8(u8"\uf09d");
const Icon FontAwesome_Feed = Icon::fromUTF8(u8"\uf09e");
const Icon FontAwesome_Rss = Icon::fromUTF8(u8"\uf09e");
const Icon FontAwesome_HddO = Icon::fromUTF8(u8"\uf0a0");
const Icon FontAwesome_Bullhorn = Icon::fromUTF8(u8"\uf0a1");
const Icon FontAwesome_Bell = Icon::fromUTF8(u8"\uf0f3");
const Icon FontAwesome_Certificate = Icon::fromUTF8(u8"\uf0a3");
const Icon FontAwesome_HandORight = Icon::fromUTF8(u8"\uf0a4");
const Icon FontAwesome_HandOLeft = Icon::fromUTF8(u8"\uf0a5");
const Icon FontAwesome_HandOUp = Icon::fromUTF8(u8"\uf0a6");
const Icon FontAwesome_HandODown = Icon::fromUTF8(u8"\uf0a7");
const Icon FontAwesome_ArrowCircleLeft = Icon::fromUTF8(u8"\uf0a8");
const Icon FontAwesome_ArrowCircleRight = Icon::fromUTF8(u8"\uf0a9");
const Icon FontAwesome_ArrowCircleUp = Icon::fromUTF8(u8"\uf0aa");
const Icon FontAwesome_ArrowCircleDown = Icon::fromUTF8(u8"\uf0ab");
const Icon FontAwesome_Globe = Icon::fromUTF8(u8"\uf0ac");
const Icon FontAwesome_Wrench = Icon::fromUTF8(u8"\uf0ad");
const Icon FontAwesome_Tasks = Icon::fromUTF8(u8"\uf0ae");
const Icon FontAwesome_Filter = Icon::fromUTF8(u8"\uf0b0");
const Icon FontAwesome_Briefcase = Icon::fromUTF8(u8"\uf0b1");
const Icon FontAwesome_ArrowsAlt = Icon::fromUTF8(u8"\uf0b2");
const Icon FontAwesome_Group = Icon::fromUTF8(u8"\uf0c0");
const Icon FontAwesome_Users = Icon::fromUTF8(u8"\uf0c0");
const Icon FontAwesome_Chain = Icon::fromUTF8(u8"\uf0c1");
const Icon FontAwesome_Link = Icon::fromUTF8(u8"\uf0c1");
const Icon FontAwesome_Cloud = Icon::fromUTF8(u8"\uf0c2");
const Icon FontAwesome_Flask = Icon::fromUTF8(u8"\uf0c3");
const Icon FontAwesome_Cut = Icon::fromUTF8(u8"\uf0c4");
const Icon FontAwesome_Scissors = Icon::fromUTF8(u8"\uf0c4");
const Icon FontAwesome_Copy = Icon::fromUTF8(u8"\uf0c5");
const Icon FontAwesome_FilesO = Icon::fromUTF8(u8"\uf0c5");
const Icon FontAwesome_Paperclip = Icon::fromUTF8(u8"\uf0c6");
const Icon FontAwesome_Save = Icon::fromUTF8(u8"\uf0c7");
const Icon FontAwesome_FloppyO = Icon::fromUTF8(u8"\uf0c7");
const Icon FontAwesome_Square = Icon::fromUTF8(u8"\uf0c8");
const Icon FontAwesome_Navicon = Icon::fromUTF8(u8"\uf0c9");
const Icon FontAwesome_Reorder = Icon::fromUTF8(u8"\uf0c9");
const Icon FontAwesome_Bars = Icon::fromUTF8(u8"\uf0c9");
const Icon FontAwesome_ListUl = Icon::fromUTF8(u8"\uf0ca");
const Icon FontAwesome_ListOl = Icon::fromUTF8(u8"\uf0cb");
const Icon FontAwesome_Strikethrough = Icon::fromUTF8(u8"\uf0cc");
const Icon FontAwesome_Underline = Icon::fromUTF8(u8"\uf0cd");
const Icon FontAwesome_Table = Icon::fromUTF8(u8"\uf0ce");
const Icon FontAwesome_Magic = Icon::fromUTF8(u8"\uf0d0");
const Icon FontAwesome_Truck = Icon::fromUTF8(u8"\uf0d1");
const Icon FontAwesome_Pinterest = Icon::fromUTF8(u8"\uf0d2");
const Icon FontAwesome_PinterestSquare = Icon::fromUTF8(u8"\uf0d3");
const Icon FontAwesome_GooglePlusSquare = Icon::fromUTF8(u8"\uf0d4");
const Icon FontAwesome_GooglePlus = Icon::fromUTF8(u8"\uf0d5");
const Icon FontAwesome_Money = Icon::fromUTF8(u8"\uf0d6");
const Icon FontAwesome_CaretDown = Icon::fromUTF8(u8"\uf0d7");
const Icon FontAwesome_CaretUp = Icon::fromUTF8(u8"\uf0d8");
const Icon FontAwesome_CaretLeft = Icon::fromUTF8(u8"\uf0d9");
const Icon FontAwesome_CaretRight = Icon::fromUTF8(u8"\uf0da");
const Icon FontAwesome_Columns = Icon::fromUTF8(u8"\uf0db");
const Icon FontAwesome_Unsorted = Icon::fromUTF8(u8"\uf0dc");
const Icon FontAwesome_Sort = Icon::fromUTF8(u8"\uf0dc");
const Icon FontAwesome_SortDown = Icon::fromUTF8(u8"\uf0dd");
const Icon FontAwesome_SortDesc = Icon::fromUTF8(u8"\uf0dd");
const Icon FontAwesome_SortUp = Icon::fromUTF8(u8"\uf0de");
const Icon FontAwesome_SortAsc = Icon::fromUTF8(u8"\uf0de");
const Icon FontAwesome_Envelope = Icon::fromUTF8(u8"\uf0e0");
const Icon FontAwesome_Linkedin = Icon::fromUTF8(u8"\uf0e1");
const Icon FontAwesome_RotateLeft = Icon::fromUTF8(u8"\uf0e2");
const Icon FontAwesome_Undo = Icon::fromUTF8(u8"\uf0e2");
const Icon FontAwesome_Legal = Icon::fromUTF8(u8"\uf0e3");
const Icon FontAwesome_Gavel = Icon::fromUTF8(u8"\uf0e3");
const Icon FontAwesome_Dashboard = Icon::fromUTF8(u8"\uf0e4");
const Icon FontAwesome_Tachometer = Icon::fromUTF8(u8"\uf0e4");
const Icon FontAwesome_CommentO = Icon::fromUTF8(u8"\uf0e5");
const Icon FontAwesome_CommentsO = Icon::fromUTF8(u8"\uf0e6");
const Icon FontAwesome_Flash = Icon::fromUTF8(u8"\uf0e7");
const Icon FontAwesome_Bolt = Icon::fromUTF8(u8"\uf0e7");
const Icon FontAwesome_Sitemap = Icon::fromUTF8(u8"\uf0e8");
const Icon FontAwesome_Umbrella = Icon::fromUTF8(u8"\uf0e9");
const Icon FontAwesome_Paste = Icon::fromUTF8(u8"\uf0ea");
const Icon FontAwesome_Clipboard = Icon::fromUTF8(u8"\uf0ea");
const Icon FontAwesome_LightbulbO = Icon::fromUTF8(u8"\uf0eb");
const Icon FontAwesome_Exchange = Icon::fromUTF8(u8"\uf0ec");
const Icon FontAwesome_CloudDownload = Icon::fromUTF8(u8"\uf0ed");
const Icon FontAwesome_CloudUpload = Icon::fromUTF8(u8"\uf0ee");
const Icon FontAwesome_UserMd = Icon::fromUTF8(u8"\uf0f0");
const Icon FontAwesome_Stethoscope = Icon::fromUTF8(u8"\uf0f1");
const Icon FontAwesome_Suitcase = Icon::fromUTF8(u8"\uf0f2");
const Icon FontAwesome_BellO = Icon::fromUTF8(u8"\uf0a2");
const Icon FontAwesome_Coffee = Icon::fromUTF8(u8"\uf0f4");
const Icon FontAwesome_Cutlery = Icon::fromUTF8(u8"\uf0f5");
const Icon FontAwesome_FileTextO = Icon::fromUTF8(u8"\uf0f6");
const Icon FontAwesome_BuildingO = Icon::fromUTF8(u8"\uf0f7");
const Icon FontAwesome_HospitalO = Icon::fromUTF8(u8"\uf0f8");
const Icon FontAwesome_Ambulance = Icon::fromUTF8(u8"\uf0f9");
const Icon FontAwesome_Medkit = Icon::fromUTF8(u8"\uf0fa");
const Icon FontAwesome_FighterJet = Icon::fromUTF8(u8"\uf0fb");
const Icon FontAwesome_Beer = Icon::fromUTF8(u8"\uf0fc");
const Icon FontAwesome_HSquare = Icon::fromUTF8(u8"\uf0fd");
const Icon FontAwesome_PlusSquare = Icon::fromUTF8(u8"\uf0fe");
const Icon FontAwesome_AngleDoubleLeft = Icon::fromUTF8(u8"\uf100");
const Icon FontAwesome_AngleDoubleRight = Icon::fromUTF8(u8"\uf101");
const Icon FontAwesome_AngleDoubleUp = Icon::fromUTF8(u8"\uf102");
const Icon FontAwesome_AngleDoubleDown = Icon::fromUTF8(u8"\uf103");
const Icon FontAwesome_AngleLeft = Icon::fromUTF8(u8"\uf104");
const Icon FontAwesome_AngleRight = Icon::fromUTF8(u8"\uf105");
const Icon FontAwesome_AngleUp = Icon::fromUTF8(u8"\uf106");
const Icon FontAwesome_AngleDown = Icon::fromUTF8(u8"\uf107");
const Icon FontAwesome_Desktop = Icon::fromUTF8(u8"\uf108");
const Icon FontAwesome_Laptop = Icon::fromUTF8(u8"\uf109");
const Icon FontAwesome_Tablet = Icon::fromUTF8(u8"\uf10a");
const Icon FontAwesome_MobilePhone = Icon::fromUTF8(u8"\uf10b");
const Icon FontAwesome_Mobile = Icon::fromUTF8(u8"\uf10b");
const Icon FontAwesome_CircleO = Icon::fromUTF8(u8"\uf10c");
const Icon FontAwesome_QuoteLeft = Icon::fromUTF8(u8"\uf10d");
const Icon FontAwesome_QuoteRight = Icon::fromUTF8(u8"\uf10e");
const Icon FontAwesome_Spinner = Icon::fromUTF8(u8"\uf110");
const Icon FontAwesome_Circle = Icon::fromUTF8(u8"\uf111");
const Icon FontAwesome_MailReply = Icon::fromUTF8(u8"\uf112");
const Icon FontAwesome_Reply = Icon::fromUTF8(u8"\uf112");
const Icon FontAwesome_GithubAlt = Icon::fromUTF8(u8"\uf113");
const Icon FontAwesome_FolderO = Icon::fromUTF8(u8"\uf114");
const Icon FontAwesome_FolderOpenO = Icon::fromUTF8(u8"\uf115");
const Icon FontAwesome_SmileO = Icon::fromUTF8(u8"\uf118");
const Icon FontAwesome_FrownO = Icon::fromUTF8(u8"\uf119");
const Icon FontAwesome_MehO = Icon::fromUTF8(u8"\uf11a");
const Icon FontAwesome_Gamepad = Icon::fromUTF8(u8"\uf11b");
const Icon FontAwesome_KeyboardO = Icon::fromUTF8(u8"\uf11c");
const Icon FontAwesome_FlagO = Icon::fromUTF8(u8"\uf11d");
const Icon FontAwesome_FlagCheckered = Icon::fromUTF8(u8"\uf11e");
const Icon FontAwesome_Terminal = Icon::fromUTF8(u8"\uf120");
const Icon FontAwesome_Code = Icon::fromUTF8(u8"\uf121");
const Icon FontAwesome_MailReplyAll = Icon::fromUTF8(u8"\uf122");
const Icon FontAwesome_ReplyAll = Icon::fromUTF8(u8"\uf122");
const Icon FontAwesome_StarHalfEmpty = Icon::fromUTF8(u8"\uf123");
const Icon FontAwesome_StarHalfFull = Icon::fromUTF8(u8"\uf123");
const Icon FontAwesome_StarHalfO = Icon::fromUTF8(u8"\uf123");
const Icon FontAwesome_LocationArrow = Icon::fromUTF8(u8"\uf124");
const Icon FontAwesome_Crop = Icon::fromUTF8(u8"\uf125");
const Icon FontAwesome_CodeFork = Icon::fromUTF8(u8"\uf126");
const Icon FontAwesome_Unlink = Icon::fromUTF8(u8"\uf127");
const Icon FontAwesome_ChainBroken = Icon::fromUTF8(u8"\uf127");
const Icon FontAwesome_Question = Icon::fromUTF8(u8"\uf128");
const Icon FontAwesome_Info = Icon::fromUTF8(u8"\uf129");
const Icon FontAwesome_Exclamation = Icon::fromUTF8(u8"\uf12a");
const Icon FontAwesome_Superscript = Icon::fromUTF8(u8"\uf12b");
const Icon FontAwesome_Subscript = Icon::fromUTF8(u8"\uf12c");
const Icon FontAwesome_Eraser = Icon::fromUTF8(u8"\uf12d");
const Icon FontAwesome_PuzzlePiece = Icon::fromUTF8(u8"\uf12e");
const Icon FontAwesome_Microphone = Icon::fromUTF8(u8"\uf130");
const Icon FontAwesome_MicrophoneSlash = Icon::fromUTF8(u8"\uf131");
const Icon FontAwesome_Shield = Icon::fromUTF8(u8"\uf132");
const Icon FontAwesome_CalendarO = Icon::fromUTF8(u8"\uf133");
const Icon FontAwesome_FireExtinguisher = Icon::fromUTF8(u8"\uf134");
const Icon FontAwesome_Rocket = Icon::fromUTF8(u8"\uf135");
const Icon FontAwesome_Maxcdn = Icon::fromUTF8(u8"\uf136");
const Icon FontAwesome_ChevronCircleLeft = Icon::fromUTF8(u8"\uf137");
const Icon FontAwesome_ChevronCircleRight = Icon::fromUTF8(u8"\uf138");
const Icon FontAwesome_ChevronCircleUp = Icon::fromUTF8(u8"\uf139");
const Icon FontAwesome_ChevronCircleDown = Icon::fromUTF8(u8"\uf13a");
const Icon FontAwesome_Html5 = Icon::fromUTF8(u8"\uf13b");
const Icon FontAwesome_Css3 = Icon::fromUTF8(u8"\uf13c");
const Icon FontAwesome_Anchor = Icon::fromUTF8(u8"\uf13d");
const Icon FontAwesome_UnlockAlt = Icon::fromUTF8(u8"\uf13e");
const Icon FontAwesome_Bullseye = Icon::fromUTF8(u8"\uf140");
const Icon FontAwesome_EllipsisH = Icon::fromUTF8(u8"\uf141");
const Icon FontAwesome_EllipsisV = Icon::fromUTF8(u8"\uf142");
const Icon FontAwesome_RssSquare = Icon::fromUTF8(u8"\uf143");
const Icon FontAwesome_PlayCircle = Icon::fromUTF8(u8"\uf144");
const Icon FontAwesome_Ticket = Icon::fromUTF8(u8"\uf145");
const Icon FontAwesome_MinusSquare = Icon::fromUTF8(u8"\uf146");
const Icon FontAwesome_MinusSquareO = Icon::fromUTF8(u8"\uf147");
const Icon FontAwesome_LevelUp = Icon::fromUTF8(u8"\uf148");
const Icon FontAwesome_LevelDown = Icon::fromUTF8(u8"\uf149");
const Icon FontAwesome_CheckSquare = Icon::fromUTF8(u8"\uf14a");
const Icon FontAwesome_PencilSquare = Icon::fromUTF8(u8"\uf14b");
const Icon FontAwesome_ExternalLinkSquare = Icon::fromUTF8(u8"\uf14c");
const Icon FontAwesome_ShareSquare = Icon::fromUTF8(u8"\uf14d");
const Icon FontAwesome_Compass = Icon::fromUTF8(u8"\uf14e");
const Icon FontAwesome_ToggleDown = Icon::fromUTF8(u8"\uf150");
const Icon FontAwesome_CaretSquareODown = Icon::fromUTF8(u8"\uf150");
const Icon FontAwesome_ToggleUp = Icon::fromUTF8(u8"\uf151");
const Icon FontAwesome_CaretSquareOUp = Icon::fromUTF8(u8"\uf151");
const Icon FontAwesome_ToggleRight = Icon::fromUTF8(u8"\uf152");
const Icon FontAwesome_CaretSquareORight = Icon::fromUTF8(u8"\uf152");
const Icon FontAwesome_Euro = Icon::fromUTF8(u8"\uf153");
const Icon FontAwesome_Eur = Icon::fromUTF8(u8"\uf153");
const Icon FontAwesome_Gbp = Icon::fromUTF8(u8"\uf154");
const Icon FontAwesome_Dollar = Icon::fromUTF8(u8"\uf155");
const Icon FontAwesome_Usd = Icon::fromUTF8(u8"\uf155");
const Icon FontAwesome_Rupee = Icon::fromUTF8(u8"\uf156");
const Icon FontAwesome_Inr = Icon::fromUTF8(u8"\uf156");
const Icon FontAwesome_Cny = Icon::fromUTF8(u8"\uf157");
const Icon FontAwesome_Rmb = Icon::fromUTF8(u8"\uf157");
const Icon FontAwesome_Yen = Icon::fromUTF8(u8"\uf157");
const Icon FontAwesome_Jpy = Icon::fromUTF8(u8"\uf157");
const Icon FontAwesome_Ruble = Icon::fromUTF8(u8"\uf158");
const Icon FontAwesome_Rouble = Icon::fromUTF8(u8"\uf158");
const Icon FontAwesome_Rub = Icon::fromUTF8(u8"\uf158");
const Icon FontAwesome_Won = Icon::fromUTF8(u8"\uf159");
const Icon FontAwesome_Krw = Icon::fromUTF8(u8"\uf159");
const Icon FontAwesome_Bitcoin = Icon::fromUTF8(u8"\uf15a");
const Icon FontAwesome_Btc = Icon::fromUTF8(u8"\uf15a");
const Icon FontAwesome_File = Icon::fromUTF8(u8"\uf15b");
const Icon FontAwesome_FileText = Icon::fromUTF8(u8"\uf15c");
const Icon FontAwesome_SortAlphaAsc = Icon::fromUTF8(u8"\uf15d");
const Icon FontAwesome_SortAlphaDesc = Icon::fromUTF8(u8"\uf15e");
const Icon FontAwesome_SortAmountAsc = Icon::fromUTF8(u8"\uf160");
const Icon FontAwesome_SortAmountDesc = Icon::fromUTF8(u8"\uf161");
const Icon FontAwesome_SortNumericAsc = Icon::fromUTF8(u8"\uf162");
const Icon FontAwesome_SortNumericDesc = Icon::fromUTF8(u8"\uf163");
const Icon FontAwesome_ThumbsUp = Icon::fromUTF8(u8"\uf164");
const Icon FontAwesome_ThumbsDown = Icon::fromUTF8(u8"\uf165");
const Icon FontAwesome_YoutubeSquare = Icon::fromUTF8(u8"\uf166");
const Icon FontAwesome_Youtube = Icon::fromUTF8(u8"\uf167");
const Icon FontAwesome_Xing = Icon::fromUTF8(u8"\uf168");
const Icon FontAwesome_XingSquare = Icon::fromUTF8(u8"\uf169");
const Icon FontAwesome_YoutubePlay = Icon::fromUTF8(u8"\uf16a");
const Icon FontAwesome_Dropbox = Icon::fromUTF8(u8"\uf16b");
const Icon FontAwesome_StackOverflow = Icon::fromUTF8(u8"\uf16c");
const Icon FontAwesome_Instagram = Icon::fromUTF8(u8"\uf16d");
const Icon FontAwesome_Flickr = Icon::fromUTF8(u8"\uf16e");
const Icon FontAwesome_Adn = Icon::fromUTF8(u8"\uf170");
const Icon FontAwesome_Bitbucket = Icon::fromUTF8(u8"\uf171");
const Icon FontAwesome_BitbucketSquare = Icon::fromUTF8(u8"\uf172");
const Icon FontAwesome_Tumblr = Icon::fromUTF8(u8"\uf173");
const Icon FontAwesome_TumblrSquare = Icon::fromUTF8(u8"\uf174");
const Icon FontAwesome_LongArrowDown = Icon::fromUTF8(u8"\uf175");
const Icon FontAwesome_LongArrowUp = Icon::fromUTF8(u8"\uf176");
const Icon FontAwesome_LongArrowLeft = Icon::fromUTF8(u8"\uf177");
const Icon FontAwesome_LongArrowRight = Icon::fromUTF8(u8"\uf178");
const Icon FontAwesome_Apple = Icon::fromUTF8(u8"\uf179");
const Icon FontAwesome_Windows = Icon::fromUTF8(u8"\uf17a");
const Icon FontAwesome_Android = Icon::fromUTF8(u8"\uf17b");
const Icon FontAwesome_Linux = Icon::fromUTF8(u8"\uf17c");
const Icon FontAwesome_Dribbble = Icon::fromUTF8(u8"\uf17d");
const Icon FontAwesome_Skype = Icon::fromUTF8(u8"\uf17e");
const Icon FontAwesome_Foursquare = Icon::fromUTF8(u8"\uf180");
const Icon FontAwesome_Trello = Icon::fromUTF8(u8"\uf181");
const Icon FontAwesome_Female = Icon::fromUTF8(u8"\uf182");
const Icon FontAwesome_Male = Icon::fromUTF8(u8"\uf183");
const Icon FontAwesome_Gittip = Icon::fromUTF8(u8"\uf184");
const Icon FontAwesome_Gratipay = Icon::fromUTF8(u8"\uf184");
const Icon FontAwesome_SunO = Icon::fromUTF8(u8"\uf185");
const Icon FontAwesome_MoonO = Icon::fromUTF8(u8"\uf186");
const Icon FontAwesome_Archive = Icon::fromUTF8(u8"\uf187");
const Icon FontAwesome_Bug = Icon::fromUTF8(u8"\uf188");
const Icon FontAwesome_Vk = Icon::fromUTF8(u8"\uf189");
const Icon FontAwesome_Weibo = Icon::fromUTF8(u8"\uf18a");
const Icon FontAwesome_Renren = Icon::fromUTF8(u8"\uf18b");
const Icon FontAwesome_Pagelines = Icon::fromUTF8(u8"\uf18c");
const Icon FontAwesome_StackExchange = Icon::fromUTF8(u8"\uf18d");
const Icon FontAwesome_ArrowCircleORight = Icon::fromUTF8(u8"\uf18e");
const Icon FontAwesome_ArrowCircleOLeft = Icon::fromUTF8(u8"\uf190");
const Icon FontAwesome_ToggleLeft = Icon::fromUTF8(u8"\uf191");
const Icon FontAwesome_CaretSquareOLeft = Icon::fromUTF8(u8"\uf191");
const Icon FontAwesome_DotCircleO = Icon::fromUTF8(u8"\uf192");
const Icon FontAwesome_Wheelchair = Icon::fromUTF8(u8"\uf193");
const Icon FontAwesome_VimeoSquare = Icon::fromUTF8(u8"\uf194");
const Icon FontAwesome_TurkishLira = Icon::fromUTF8(u8"\uf195");
const Icon FontAwesome_Try = Icon::fromUTF8(u8"\uf195");
const Icon FontAwesome_PlusSquareO = Icon::fromUTF8(u8"\uf196");
const Icon FontAwesome_SpaceShuttle = Icon::fromUTF8(u8"\uf197");
const Icon FontAwesome_Slack = Icon::fromUTF8(u8"\uf198");
const Icon FontAwesome_EnvelopeSquare = Icon::fromUTF8(u8"\uf199");
const Icon FontAwesome_Wordpress = Icon::fromUTF8(u8"\uf19a");
const Icon FontAwesome_Openid = Icon::fromUTF8(u8"\uf19b");
const Icon FontAwesome_Institution = Icon::fromUTF8(u8"\uf19c");
const Icon FontAwesome_Bank = Icon::fromUTF8(u8"\uf19c");
const Icon FontAwesome_University = Icon::fromUTF8(u8"\uf19c");
const Icon FontAwesome_MortarBoard = Icon::fromUTF8(u8"\uf19d");
const Icon FontAwesome_GraduationCap = Icon::fromUTF8(u8"\uf19d");
const Icon FontAwesome_Yahoo = Icon::fromUTF8(u8"\uf19e");
const Icon FontAwesome_Google = Icon::fromUTF8(u8"\uf1a0");
const Icon FontAwesome_Reddit = Icon::fromUTF8(u8"\uf1a1");
const Icon FontAwesome_RedditSquare = Icon::fromUTF8(u8"\uf1a2");
const Icon FontAwesome_StumbleuponCircle = Icon::fromUTF8(u8"\uf1a3");
const Icon FontAwesome_Stumbleupon = Icon::fromUTF8(u8"\uf1a4");
const Icon FontAwesome_Delicious = Icon::fromUTF8(u8"\uf1a5");
const Icon FontAwesome_Digg = Icon::fromUTF8(u8"\uf1a6");
const Icon FontAwesome_PiedPiperPp = Icon::fromUTF8(u8"\uf1a7");
const Icon FontAwesome_PiedPiperAlt = Icon::fromUTF8(u8"\uf1a8");
const Icon FontAwesome_Drupal = Icon::fromUTF8(u8"\uf1a9");
const Icon FontAwesome_Joomla = Icon::fromUTF8(u8"\uf1aa");
const Icon FontAwesome_Language = Icon::fromUTF8(u8"\uf1ab");
const Icon FontAwesome_Fax = Icon::fromUTF8(u8"\uf1ac");
const Icon FontAwesome_Building = Icon::fromUTF8(u8"\uf1ad");
const Icon FontAwesome_Child = Icon::fromUTF8(u8"\uf1ae");
const Icon FontAwesome_Paw = Icon::fromUTF8(u8"\uf1b0");
const Icon FontAwesome_Spoon = Icon::fromUTF8(u8"\uf1b1");
const Icon FontAwesome_Cube = Icon::fromUTF8(u8"\uf1b2");
const Icon FontAwesome_Cubes = Icon::fromUTF8(u8"\uf1b3");
const Icon FontAwesome_Behance = Icon::fromUTF8(u8"\uf1b4");
const Icon FontAwesome_BehanceSquare = Icon::fromUTF8(u8"\uf1b5");
const Icon FontAwesome_Steam = Icon::fromUTF8(u8"\uf1b6");
const Icon FontAwesome_SteamSquare = Icon::fromUTF8(u8"\uf1b7");
const Icon FontAwesome_Recycle = Icon::fromUTF8(u8"\uf1b8");
const Icon FontAwesome_Automobile = Icon::fromUTF8(u8"\uf1b9");
const Icon FontAwesome_Car = Icon::fromUTF8(u8"\uf1b9");
const Icon FontAwesome_Cab = Icon::fromUTF8(u8"\uf1ba");
const Icon FontAwesome_Taxi = Icon::fromUTF8(u8"\uf1ba");
const Icon FontAwesome_Tree = Icon::fromUTF8(u8"\uf1bb");
const Icon FontAwesome_Spotify = Icon::fromUTF8(u8"\uf1bc");
const Icon FontAwesome_Deviantart = Icon::fromUTF8(u8"\uf1bd");
const Icon FontAwesome_Soundcloud = Icon::fromUTF8(u8"\uf1be");
const Icon FontAwesome_Database = Icon::fromUTF8(u8"\uf1c0");
const Icon FontAwesome_FilePdfO = Icon::fromUTF8(u8"\uf1c1");
const Icon FontAwesome_FileWordO = Icon::fromUTF8(u8"\uf1c2");
const Icon FontAwesome_FileExcelO = Icon::fromUTF8(u8"\uf1c3");
const Icon FontAwesome_FilePowerpointO = Icon::fromUTF8(u8"\uf1c4");
const Icon FontAwesome_FilePhotoO = Icon::fromUTF8(u8"\uf1c5");
const Icon FontAwesome_FilePictureO = Icon::fromUTF8(u8"\uf1c5");
const Icon FontAwesome_FileImageO = Icon::fromUTF8(u8"\uf1c5");
const Icon FontAwesome_FileZipO = Icon::fromUTF8(u8"\uf1c6");
const Icon FontAwesome_FileArchiveO = Icon::fromUTF8(u8"\uf1c6");
const Icon FontAwesome_FileSoundO = Icon::fromUTF8(u8"\uf1c7");
const Icon FontAwesome_FileAudioO = Icon::fromUTF8(u8"\uf1c7");
const Icon FontAwesome_FileMovieO = Icon::fromUTF8(u8"\uf1c8");
const Icon FontAwesome_FileVideoO = Icon::fromUTF8(u8"\uf1c8");
const Icon FontAwesome_FileCodeO = Icon::fromUTF8(u8"\uf1c9");
const Icon FontAwesome_Vine = Icon::fromUTF8(u8"\uf1ca");
const Icon FontAwesome_Codepen = Icon::fromUTF8(u8"\uf1cb");
const Icon FontAwesome_Jsfiddle = Icon::fromUTF8(u8"\uf1cc");
const Icon FontAwesome_LifeBouy = Icon::fromUTF8(u8"\uf1cd");
const Icon FontAwesome_LifeBuoy = Icon::fromUTF8(u8"\uf1cd");
const Icon FontAwesome_LifeSaver = Icon::fromUTF8(u8"\uf1cd");
const Icon FontAwesome_Support = Icon::fromUTF8(u8"\uf1cd");
const Icon FontAwesome_LifeRing = Icon::fromUTF8(u8"\uf1cd");
const Icon FontAwesome_CircleONotch = Icon::fromUTF8(u8"\uf1ce");
const Icon FontAwesome_Ra = Icon::fromUTF8(u8"\uf1d0");
const Icon FontAwesome_Resistance = Icon::fromUTF8(u8"\uf1d0");
const Icon FontAwesome_Rebel = Icon::fromUTF8(u8"\uf1d0");
const Icon FontAwesome_Ge = Icon::fromUTF8(u8"\uf1d1");
const Icon FontAwesome_Empire = Icon::fromUTF8(u8"\uf1d1");
const Icon FontAwesome_GitSquare = Icon::fromUTF8(u8"\uf1d2");
const Icon FontAwesome_Git = Icon::fromUTF8(u8"\uf1d3");
const Icon FontAwesome_YCombinatorSquare = Icon::fromUTF8(u8"\uf1d4");
const Icon FontAwesome_YcSquare = Icon::fromUTF8(u8"\uf1d4");
const Icon FontAwesome_HackerNews = Icon::fromUTF8(u8"\uf1d4");
const Icon FontAwesome_TencentWeibo = Icon::fromUTF8(u8"\uf1d5");
const Icon FontAwesome_Qq = Icon::fromUTF8(u8"\uf1d6");
const Icon FontAwesome_Wechat = Icon::fromUTF8(u8"\uf1d7");
const Icon FontAwesome_Weixin = Icon::fromUTF8(u8"\uf1d7");
const Icon FontAwesome_Send = Icon::fromUTF8(u8"\uf1d8");
const Icon FontAwesome_PaperPlane = Icon::fromUTF8(u8"\uf1d8");
const Icon FontAwesome_SendO = Icon::fromUTF8(u8"\uf1d9");
const Icon FontAwesome_PaperPlaneO = Icon::fromUTF8(u8"\uf1d9");
const Icon FontAwesome_History = Icon::fromUTF8(u8"\uf1da");
const Icon FontAwesome_CircleThin = Icon::fromUTF8(u8"\uf1db");
const Icon FontAwesome_Header = Icon::fromUTF8(u8"\uf1dc");
const Icon FontAwesome_Paragraph = Icon::fromUTF8(u8"\uf1dd");
const Icon FontAwesome_Sliders = Icon::fromUTF8(u8"\uf1de");
const Icon FontAwesome_ShareAlt = Icon::fromUTF8(u8"\uf1e0");
const Icon FontAwesome_ShareAltSquare = Icon::fromUTF8(u8"\uf1e1");
const Icon FontAwesome_Bomb = Icon::fromUTF8(u8"\uf1e2");
const Icon FontAwesome_SoccerBallO = Icon::fromUTF8(u8"\uf1e3");
const Icon FontAwesome_FutbolO = Icon::fromUTF8(u8"\uf1e3");
const Icon FontAwesome_Tty = Icon::fromUTF8(u8"\uf1e4");
const Icon FontAwesome_Binoculars = Icon::fromUTF8(u8"\uf1e5");
const Icon FontAwesome_Plug = Icon::fromUTF8(u8"\uf1e6");
const Icon FontAwesome_Slideshare = Icon::fromUTF8(u8"\uf1e7");
const Icon FontAwesome_Twitch = Icon::fromUTF8(u8"\uf1e8");
const Icon FontAwesome_Yelp = Icon::fromUTF8(u8"\uf1e9");
const Icon FontAwesome_NewspaperO = Icon::fromUTF8(u8"\uf1ea");
const Icon FontAwesome_Wifi = Icon::fromUTF8(u8"\uf1eb");
const Icon FontAwesome_Calculator = Icon::fromUTF8(u8"\uf1ec");
const Icon FontAwesome_Paypal = Icon::fromUTF8(u8"\uf1ed");
const Icon FontAwesome_GoogleWallet = Icon::fromUTF8(u8"\uf1ee");
const Icon FontAwesome_CcVisa = Icon::fromUTF8(u8"\uf1f0");
const Icon FontAwesome_CcMastercard = Icon::fromUTF8(u8"\uf1f1");
const Icon FontAwesome_CcDiscover = Icon::fromUTF8(u8"\uf1f2");
const Icon FontAwesome_CcAmex = Icon::fromUTF8(u8"\uf1f3");
const Icon FontAwesome_CcPaypal = Icon::fromUTF8(u8"\uf1f4");
const Icon FontAwesome_CcStripe = Icon::fromUTF8(u8"\uf1f5");
const Icon FontAwesome_BellSlash = Icon::fromUTF8(u8"\uf1f6");
const Icon FontAwesome_BellSlashO = Icon::fromUTF8(u8"\uf1f7");
const Icon FontAwesome_Trash = Icon::fromUTF8(u8"\uf1f8");
const Icon FontAwesome_Copyright = Icon::fromUTF8(u8"\uf1f9");
const Icon FontAwesome_At = Icon::fromUTF8(u8"\uf1fa");
const Icon FontAwesome_Eyedropper = Icon::fromUTF8(u8"\uf1fb");
const Icon FontAwesome_PaintBrush = Icon::fromUTF8(u8"\uf1fc");
const Icon FontAwesome_BirthdayCake = Icon::fromUTF8(u8"\uf1fd");
const Icon FontAwesome_AreaChart = Icon::fromUTF8(u8"\uf1fe");
const Icon FontAwesome_PieChart = Icon::fromUTF8(u8"\uf200");
const Icon FontAwesome_LineChart = Icon::fromUTF8(u8"\uf201");
const Icon FontAwesome_Lastfm = Icon::fromUTF8(u8"\uf202");
const Icon FontAwesome_LastfmSquare = Icon::fromUTF8(u8"\uf203");
const Icon FontAwesome_ToggleOff = Icon::fromUTF8(u8"\uf204");
const Icon FontAwesome_ToggleOn = Icon::fromUTF8(u8"\uf205");
const Icon FontAwesome_Bicycle = Icon::fromUTF8(u8"\uf206");
const Icon FontAwesome_Bus = Icon::fromUTF8(u8"\uf207");
const Icon FontAwesome_Ioxhost = Icon::fromUTF8(u8"\uf208");
const Icon FontAwesome_Angellist = Icon::fromUTF8(u8"\uf209");
const Icon FontAwesome_Cc = Icon::fromUTF8(u8"\uf20a");
const Icon FontAwesome_Shekel = Icon::fromUTF8(u8"\uf20b");
const Icon FontAwesome_Sheqel = Icon::fromUTF8(u8"\uf20b");
const Icon FontAwesome_Ils = Icon::fromUTF8(u8"\uf20b");
const Icon FontAwesome_Meanpath = Icon::fromUTF8(u8"\uf20c");
const Icon FontAwesome_Buysellads = Icon::fromUTF8(u8"\uf20d");
const Icon FontAwesome_Connectdevelop = Icon::fromUTF8(u8"\uf20e");
const Icon FontAwesome_Dashcube = Icon::fromUTF8(u8"\uf210");
const Icon FontAwesome_Forumbee = Icon::fromUTF8(u8"\uf211");
const Icon FontAwesome_Leanpub = Icon::fromUTF8(u8"\uf212");
const Icon FontAwesome_Sellsy = Icon::fromUTF8(u8"\uf213");
const Icon FontAwesome_Shirtsinbulk = Icon::fromUTF8(u8"\uf214");
const Icon FontAwesome_Simplybuilt = Icon::fromUTF8(u8"\uf215");
const Icon FontAwesome_Skyatlas = Icon::fromUTF8(u8"\uf216");
const Icon FontAwesome_CartPlus = Icon::fromUTF8(u8"\uf217");
const Icon FontAwesome_CartArrowDown = Icon::fromUTF8(u8"\uf218");
const Icon FontAwesome_Diamond = Icon::fromUTF8(u8"\uf219");
const Icon FontAwesome_Ship = Icon::fromUTF8(u8"\uf21a");
const Icon FontAwesome_UserSecret = Icon::fromUTF8(u8"\uf21b");
const Icon FontAwesome_Motorcycle = Icon::fromUTF8(u8"\uf21c");
const Icon FontAwesome_StreetView = Icon::fromUTF8(u8"\uf21d");
const Icon FontAwesome_Heartbeat = Icon::fromUTF8(u8"\uf21e");
const Icon FontAwesome_Venus = Icon::fromUTF8(u8"\uf221");
const Icon FontAwesome_Mars = Icon::fromUTF8(u8"\uf222");
const Icon FontAwesome_Mercury = Icon::fromUTF8(u8"\uf223");
const Icon FontAwesome_Intersex = Icon::fromUTF8(u8"\uf224");
const Icon FontAwesome_Transgender = Icon::fromUTF8(u8"\uf224");
const Icon FontAwesome_TransgenderAlt = Icon::fromUTF8(u8"\uf225");
const Icon FontAwesome_VenusDouble = Icon::fromUTF8(u8"\uf226");
const Icon FontAwesome_MarsDouble = Icon::fromUTF8(u8"\uf227");
const Icon FontAwesome_VenusMars = Icon::fromUTF8(u8"\uf228");
const Icon FontAwesome_MarsStroke = Icon::fromUTF8(u8"\uf229");
const Icon FontAwesome_MarsStrokeV = Icon::fromUTF8(u8"\uf22a");
const Icon FontAwesome_MarsStrokeH = Icon::fromUTF8(u8"\uf22b");
const Icon FontAwesome_Neuter = Icon::fromUTF8(u8"\uf22c");
const Icon FontAwesome_Genderless = Icon::fromUTF8(u8"\uf22d");
const Icon FontAwesome_FacebookOfficial = Icon::fromUTF8(u8"\uf230");
const Icon FontAwesome_PinterestP = Icon::fromUTF8(u8"\uf231");
const Icon FontAwesome_Whatsapp = Icon::fromUTF8(u8"\uf232");
const Icon FontAwesome_Server = Icon::fromUTF8(u8"\uf233");
const Icon FontAwesome_UserPlus = Icon::fromUTF8(u8"\uf234");
const Icon FontAwesome_UserTimes = Icon::fromUTF8(u8"\uf235");
const Icon FontAwesome_Hotel = Icon::fromUTF8(u8"\uf236");
const Icon FontAwesome_Bed = Icon::fromUTF8(u8"\uf236");
const Icon FontAwesome_Viacoin = Icon::fromUTF8(u8"\uf237");
const Icon FontAwesome_Train = Icon::fromUTF8(u8"\uf238");
const Icon FontAwesome_Subway = Icon::fromUTF8(u8"\uf239");
const Icon FontAwesome_Medium = Icon::fromUTF8(u8"\uf23a");
const Icon FontAwesome_Yc = Icon::fromUTF8(u8"\uf23b");
const Icon FontAwesome_YCombinator = Icon::fromUTF8(u8"\uf23b");
const Icon FontAwesome_OptinMonster = Icon::fromUTF8(u8"\uf23c");
const Icon FontAwesome_Opencart = Icon::fromUTF8(u8"\uf23d");
const Icon FontAwesome_Expeditedssl = Icon::fromUTF8(u8"\uf23e");
const Icon FontAwesome_Battery4 = Icon::fromUTF8(u8"\uf240");
const Icon FontAwesome_Battery = Icon::fromUTF8(u8"\uf240");
const Icon FontAwesome_BatteryFull = Icon::fromUTF8(u8"\uf240");
const Icon FontAwesome_Battery3 = Icon::fromUTF8(u8"\uf241");
const Icon FontAwesome_BatteryThreeQuarters = Icon::fromUTF8(u8"\uf241");
const Icon FontAwesome_Battery2 = Icon::fromUTF8(u8"\uf242");
const Icon FontAwesome_BatteryHalf = Icon::fromUTF8(u8"\uf242");
const Icon FontAwesome_Battery1 = Icon::fromUTF8(u8"\uf243");
const Icon FontAwesome_BatteryQuarter = Icon::fromUTF8(u8"\uf243");
const Icon FontAwesome_Battery0 = Icon::fromUTF8(u8"\uf244");
const Icon FontAwesome_BatteryEmpty = Icon::fromUTF8(u8"\uf244");
const Icon FontAwesome_MousePointer = Icon::fromUTF8(u8"\uf245");
const Icon FontAwesome_ICursor = Icon::fromUTF8(u8"\uf246");
const Icon FontAwesome_ObjectGroup = Icon::fromUTF8(u8"\uf247");
const Icon FontAwesome_ObjectUngroup = Icon::fromUTF8(u8"\uf248");
const Icon FontAwesome_StickyNote = Icon::fromUTF8(u8"\uf249");
const Icon FontAwesome_StickyNoteO = Icon::fromUTF8(u8"\uf24a");
const Icon FontAwesome_CcJcb = Icon::fromUTF8(u8"\uf24b");
const Icon FontAwesome_CcDinersClub = Icon::fromUTF8(u8"\uf24c");
const Icon FontAwesome_Clone = Icon::fromUTF8(u8"\uf24d");
const Icon FontAwesome_BalanceScale = Icon::fromUTF8(u8"\uf24e");
const Icon FontAwesome_HourglassO = Icon::fromUTF8(u8"\uf250");
const Icon FontAwesome_Hourglass1 = Icon::fromUTF8(u8"\uf251");
const Icon FontAwesome_HourglassStart = Icon::fromUTF8(u8"\uf251");
const Icon FontAwesome_Hourglass2 = Icon::fromUTF8(u8"\uf252");
const Icon FontAwesome_HourglassHalf = Icon::fromUTF8(u8"\uf252");
const Icon FontAwesome_Hourglass3 = Icon::fromUTF8(u8"\uf253");
const Icon FontAwesome_HourglassEnd = Icon::fromUTF8(u8"\uf253");
const Icon FontAwesome_Hourglass = Icon::fromUTF8(u8"\uf254");
const Icon FontAwesome_HandGrabO = Icon::fromUTF8(u8"\uf255");
const Icon FontAwesome_HandRockO = Icon::fromUTF8(u8"\uf255");
const Icon FontAwesome_HandStopO = Icon::fromUTF8(u8"\uf256");
const Icon FontAwesome_HandPaperO = Icon::fromUTF8(u8"\uf256");
const Icon FontAwesome_HandScissorsO = Icon::fromUTF8(u8"\uf257");
const Icon FontAwesome_HandLizardO = Icon::fromUTF8(u8"\uf258");
const Icon FontAwesome_HandSpockO = Icon::fromUTF8(u8"\uf259");
const Icon FontAwesome_HandPointerO = Icon::fromUTF8(u8"\uf25a");
const Icon FontAwesome_HandPeaceO = Icon::fromUTF8(u8"\uf25b");
const Icon FontAwesome_Trademark = Icon::fromUTF8(u8"\uf25c");
const Icon FontAwesome_Registered = Icon::fromUTF8(u8"\uf25d");
const Icon FontAwesome_CreativeCommons = Icon::fromUTF8(u8"\uf25e");
const Icon FontAwesome_Gg = Icon::fromUTF8(u8"\uf260");
const Icon FontAwesome_GgCircle = Icon::fromUTF8(u8"\uf261");
const Icon FontAwesome_Tripadvisor = Icon::fromUTF8(u8"\uf262");
const Icon FontAwesome_Odnoklassniki = Icon::fromUTF8(u8"\uf263");
const Icon FontAwesome_OdnoklassnikiSquare = Icon::fromUTF8(u8"\uf264");
const Icon FontAwesome_GetPocket = Icon::fromUTF8(u8"\uf265");
const Icon FontAwesome_WikipediaW = Icon::fromUTF8(u8"\uf266");
const Icon FontAwesome_Safari = Icon::fromUTF8(u8"\uf267");
const Icon FontAwesome_Chrome = Icon::fromUTF8(u8"\uf268");
const Icon FontAwesome_Firefox = Icon::fromUTF8(u8"\uf269");
const Icon FontAwesome_Opera = Icon::fromUTF8(u8"\uf26a");
const Icon FontAwesome_InternetExplorer = Icon::fromUTF8(u8"\uf26b");
const Icon FontAwesome_Tv = Icon::fromUTF8(u8"\uf26c");
const Icon FontAwesome_Television = Icon::fromUTF8(u8"\uf26c");
const Icon FontAwesome_Contao = Icon::fromUTF8(u8"\uf26d");
const Icon FontAwesome_500px = Icon::fromUTF8(u8"\uf26e");
const Icon FontAwesome_Amazon = Icon::fromUTF8(u8"\uf270");
const Icon FontAwesome_CalendarPlusO = Icon::fromUTF8(u8"\uf271");
const Icon FontAwesome_CalendarMinusO = Icon::fromUTF8(u8"\uf272");
const Icon FontAwesome_CalendarTimesO = Icon::fromUTF8(u8"\uf273");
const Icon FontAwesome_CalendarCheckO = Icon::fromUTF8(u8"\uf274");
const Icon FontAwesome_Industry = Icon::fromUTF8(u8"\uf275");
const Icon FontAwesome_MapPin = Icon::fromUTF8(u8"\uf276");
const Icon FontAwesome_MapSigns = Icon::fromUTF8(u8"\uf277");
const Icon FontAwesome_MapO = Icon::fromUTF8(u8"\uf278");
const Icon FontAwesome_Map = Icon::fromUTF8(u8"\uf279");
const Icon FontAwesome_Commenting = Icon::fromUTF8(u8"\uf27a");
const Icon FontAwesome_CommentingO = Icon::fromUTF8(u8"\uf27b");
const Icon FontAwesome_Houzz = Icon::fromUTF8(u8"\uf27c");
const Icon FontAwesome_Vimeo = Icon::fromUTF8(u8"\uf27d");
const Icon FontAwesome_BlackTie = Icon::fromUTF8(u8"\uf27e");
const Icon FontAwesome_Fonticons = Icon::fromUTF8(u8"\uf280");
const Icon FontAwesome_RedditAlien = Icon::fromUTF8(u8"\uf281");
const Icon FontAwesome_Edge = Icon::fromUTF8(u8"\uf282");
const Icon FontAwesome_CreditCardAlt = Icon::fromUTF8(u8"\uf283");
const Icon FontAwesome_Codiepie = Icon::fromUTF8(u8"\uf284");
const Icon FontAwesome_Modx = Icon::fromUTF8(u8"\uf285");
const Icon FontAwesome_FortAwesome = Icon::fromUTF8(u8"\uf286");
const Icon FontAwesome_Usb = Icon::fromUTF8(u8"\uf287");
const Icon FontAwesome_ProductHunt = Icon::fromUTF8(u8"\uf288");
const Icon FontAwesome_Mixcloud = Icon::fromUTF8(u8"\uf289");
const Icon FontAwesome_Scribd = Icon::fromUTF8(u8"\uf28a");
const Icon FontAwesome_PauseCircle = Icon::fromUTF8(u8"\uf28b");
const Icon FontAwesome_PauseCircleO = Icon::fromUTF8(u8"\uf28c");
const Icon FontAwesome_StopCircle = Icon::fromUTF8(u8"\uf28d");
const Icon FontAwesome_StopCircleO = Icon::fromUTF8(u8"\uf28e");
const Icon FontAwesome_ShoppingBag = Icon::fromUTF8(u8"\uf290");
const Icon FontAwesome_ShoppingBasket = Icon::fromUTF8(u8"\uf291");
const Icon FontAwesome_Hashtag = Icon::fromUTF8(u8"\uf292");
const Icon FontAwesome_Bluetooth = Icon::fromUTF8(u8"\uf293");
const Icon FontAwesome_BluetoothB = Icon::fromUTF8(u8"\uf294");
const Icon FontAwesome_Percent = Icon::fromUTF8(u8"\uf295");
const Icon FontAwesome_Gitlab = Icon::fromUTF8(u8"\uf296");
const Icon FontAwesome_Wpbeginner = Icon::fromUTF8(u8"\uf297");
const Icon FontAwesome_Wpforms = Icon::fromUTF8(u8"\uf298");
const Icon FontAwesome_Envira = Icon::fromUTF8(u8"\uf299");
const Icon FontAwesome_UniversalAccess = Icon::fromUTF8(u8"\uf29a");
const Icon FontAwesome_WheelchairAlt = Icon::fromUTF8(u8"\uf29b");
const Icon FontAwesome_QuestionCircleO = Icon::fromUTF8(u8"\uf29c");
const Icon FontAwesome_Blind = Icon::fromUTF8(u8"\uf29d");
const Icon FontAwesome_AudioDescription = Icon::fromUTF8(u8"\uf29e");
const Icon FontAwesome_VolumeControlPhone = Icon::fromUTF8(u8"\uf2a0");
const Icon FontAwesome_Braille = Icon::fromUTF8(u8"\uf2a1");
const Icon FontAwesome_AssistiveListeningSystems = Icon::fromUTF8(u8"\uf2a2");
const Icon FontAwesome_AslInterpreting = Icon::fromUTF8(u8"\uf2a3");
const Icon FontAwesome_AmericanSignLanguageInterpreting = Icon::fromUTF8(u8"\uf2a3");
const Icon FontAwesome_Deafness = Icon::fromUTF8(u8"\uf2a4");
const Icon FontAwesome_HardOfHearing = Icon::fromUTF8(u8"\uf2a4");
const Icon FontAwesome_Deaf = Icon::fromUTF8(u8"\uf2a4");
const Icon FontAwesome_Glide = Icon::fromUTF8(u8"\uf2a5");
const Icon FontAwesome_GlideG = Icon::fromUTF8(u8"\uf2a6");
const Icon FontAwesome_Signing = Icon::fromUTF8(u8"\uf2a7");
const Icon FontAwesome_SignLanguage = Icon::fromUTF8(u8"\uf2a7");
const Icon FontAwesome_LowVision = Icon::fromUTF8(u8"\uf2a8");
const Icon FontAwesome_Viadeo = Icon::fromUTF8(u8"\uf2a9");
const Icon FontAwesome_ViadeoSquare = Icon::fromUTF8(u8"\uf2aa");
const Icon FontAwesome_Snapchat = Icon::fromUTF8(u8"\uf2ab");
const Icon FontAwesome_SnapchatGhost = Icon::fromUTF8(u8"\uf2ac");
const Icon FontAwesome_SnapchatSquare = Icon::fromUTF8(u8"\uf2ad");
const Icon FontAwesome_PiedPiper = Icon::fromUTF8(u8"\uf2ae");
const Icon FontAwesome_FirstOrder = Icon::fromUTF8(u8"\uf2b0");
const Icon FontAwesome_Yoast = Icon::fromUTF8(u8"\uf2b1");
const Icon FontAwesome_Themeisle = Icon::fromUTF8(u8"\uf2b2");
const Icon FontAwesome_GooglePlusCircle = Icon::fromUTF8(u8"\uf2b3");
const Icon FontAwesome_GooglePlusOfficial = Icon::fromUTF8(u8"\uf2b3");
const Icon FontAwesome_Fa = Icon::fromUTF8(u8"\uf2b4");
const Icon FontAwesome_FontAwesome = Icon::fromUTF8(u8"\uf2b4");
const Icon FontAwesome_HandshakeO = Icon::fromUTF8(u8"\uf2b5");
const Icon FontAwesome_EnvelopeOpen = Icon::fromUTF8(u8"\uf2b6");
const Icon FontAwesome_EnvelopeOpenO = Icon::fromUTF8(u8"\uf2b7");
const Icon FontAwesome_Linode = Icon::fromUTF8(u8"\uf2b8");
const Icon FontAwesome_AddressBook = Icon::fromUTF8(u8"\uf2b9");
const Icon FontAwesome_AddressBookO = Icon::fromUTF8(u8"\uf2ba");
const Icon FontAwesome_Vcard = Icon::fromUTF8(u8"\uf2bb");
const Icon FontAwesome_AddressCard = Icon::fromUTF8(u8"\uf2bb");
const Icon FontAwesome_VcardO = Icon::fromUTF8(u8"\uf2bc");
const Icon FontAwesome_AddressCardO = Icon::fromUTF8(u8"\uf2bc");
const Icon FontAwesome_UserCircle = Icon::fromUTF8(u8"\uf2bd");
const Icon FontAwesome_UserCircleO = Icon::fromUTF8(u8"\uf2be");
const Icon FontAwesome_UserO = Icon::fromUTF8(u8"\uf2c0");
const Icon FontAwesome_IdBadge = Icon::fromUTF8(u8"\uf2c1");
const Icon FontAwesome_DriversLicense = Icon::fromUTF8(u8"\uf2c2");
const Icon FontAwesome_IdCard = Icon::fromUTF8(u8"\uf2c2");
const Icon FontAwesome_DriversLicenseO = Icon::fromUTF8(u8"\uf2c3");
const Icon FontAwesome_IdCardO = Icon::fromUTF8(u8"\uf2c3");
const Icon FontAwesome_Quora = Icon::fromUTF8(u8"\uf2c4");
const Icon FontAwesome_FreeCodeCamp = Icon::fromUTF8(u8"\uf2c5");
const Icon FontAwesome_Telegram = Icon::fromUTF8(u8"\uf2c6");
const Icon FontAwesome_Thermometer4 = Icon::fromUTF8(u8"\uf2c7");
const Icon FontAwesome_Thermometer = Icon::fromUTF8(u8"\uf2c7");
const Icon FontAwesome_ThermometerFull = Icon::fromUTF8(u8"\uf2c7");
const Icon FontAwesome_Thermometer3 = Icon::fromUTF8(u8"\uf2c8");
const Icon FontAwesome_ThermometerThreeQuarters = Icon::fromUTF8(u8"\uf2c8");
const Icon FontAwesome_Thermometer2 = Icon::fromUTF8(u8"\uf2c9");
const Icon FontAwesome_ThermometerHalf = Icon::fromUTF8(u8"\uf2c9");
const Icon FontAwesome_Thermometer1 = Icon::fromUTF8(u8"\uf2ca");
const Icon FontAwesome_ThermometerQuarter = Icon::fromUTF8(u8"\uf2ca");
const Icon FontAwesome_Thermometer0 = Icon::fromUTF8(u8"\uf2cb");
const Icon FontAwesome_ThermometerEmpty = Icon::fromUTF8(u8"\uf2cb");
const Icon FontAwesome_Shower = Icon::fromUTF8(u8"\uf2cc");
const Icon FontAwesome_Bathtub = Icon::fromUTF8(u8"\uf2cd");
const Icon FontAwesome_S15 = Icon::fromUTF8(u8"\uf2cd");
const Icon FontAwesome_Bath = Icon::fromUTF8(u8"\uf2cd");
const Icon FontAwesome_Podcast = Icon::fromUTF8(u8"\uf2ce");
const Icon FontAwesome_WindowMaximize = Icon::fromUTF8(u8"\uf2d0");
const Icon FontAwesome_WindowMinimize = Icon::fromUTF8(u8"\uf2d1");
const Icon FontAwesome_WindowRestore = Icon::fromUTF8(u8"\uf2d2");
const Icon FontAwesome_TimesRectangle = Icon::fromUTF8(u8"\uf2d3");
const Icon FontAwesome_WindowClose = Icon::fromUTF8(u8"\uf2d3");
const Icon FontAwesome_TimesRectangleO = Icon::fromUTF8(u8"\uf2d4");
const Icon FontAwesome_WindowCloseO = Icon::fromUTF8(u8"\uf2d4");
const Icon FontAwesome_Bandcamp = Icon::fromUTF8(u8"\uf2d5");
const Icon FontAwesome_Grav = Icon::fromUTF8(u8"\uf2d6");
const Icon FontAwesome_Etsy = Icon::fromUTF8(u8"\uf2d7");
const Icon FontAwesome_Imdb = Icon::fromUTF8(u8"\uf2d8");
const Icon FontAwesome_Ravelry = Icon::fromUTF8(u8"\uf2d9");
const Icon FontAwesome_Eercast = Icon::fromUTF8(u8"\uf2da");
const Icon FontAwesome_Microchip = Icon::fromUTF8(u8"\uf2db");
const Icon FontAwesome_SnowflakeO = Icon::fromUTF8(u8"\uf2dc");
const Icon FontAwesome_Superpowers = Icon::fromUTF8(u8"\uf2dd");
const Icon FontAwesome_Wpexplorer = Icon::fromUTF8(u8"\uf2de");
const Icon FontAwesome_Meetup = Icon::fromUTF8(u8"\uf2e0");
#endif // __FONTAWESOME_ICONS_H__
| 61.977387 | 85 | 0.77624 |
8fdfc994d16ff0839e1f334d453eac6d1079dee6 | 420 | h | C | vendor/projectb/ObjC-NSDictionary/MyClass.h | nikolay-dementiev/ObjC-HelloWorld | 6329fb1b72c0da878cbbe6db02f78e777682477e | [
"MIT"
] | null | null | null | vendor/projectb/ObjC-NSDictionary/MyClass.h | nikolay-dementiev/ObjC-HelloWorld | 6329fb1b72c0da878cbbe6db02f78e777682477e | [
"MIT"
] | null | null | null | vendor/projectb/ObjC-NSDictionary/MyClass.h | nikolay-dementiev/ObjC-HelloWorld | 6329fb1b72c0da878cbbe6db02f78e777682477e | [
"MIT"
] | null | null | null | //
// MyClass.h
// ObjC-NSDictionary
//
// Created by Nikolay Dementiev on 12.09.16.
// Copyright © 2016 mc373. All rights reserved.
//
//#ifndef MyClass_h
//#define MyClass_h
//
//
//#endif /* MyClass_h */
#import <Foundation/Foundation.h>
@interface MyClass : NSObject {
NSString *name;
NSString *adress;
}
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *adress;
@end | 16.8 | 48 | 0.685714 |
892b3735f9d8e59a8bf649788b11e2e20d2f44c4 | 488 | h | C | Tetris Game Lab/ADC.h | apahlavan1/Spring-2015-EE-319K-Labs-C-and-Assembly- | fe23deda30d16c1edf4ce12dd0199e7c95bab22e | [
"MIT"
] | 1 | 2016-01-14T05:17:39.000Z | 2016-01-14T05:17:39.000Z | Tetris Game Lab/ADC.h | apahlavan1/Spring-2015-EE-319K-Labs-C-and-Assembly- | fe23deda30d16c1edf4ce12dd0199e7c95bab22e | [
"MIT"
] | null | null | null | Tetris Game Lab/ADC.h | apahlavan1/Spring-2015-EE-319K-Labs-C-and-Assembly- | fe23deda30d16c1edf4ce12dd0199e7c95bab22e | [
"MIT"
] | 1 | 2016-12-03T06:34:59.000Z | 2016-12-03T06:34:59.000Z | // ADC.h
// Runs on LM4F120/TM4C123
// Provide functions that initialize ADC0
// Student names: Aria Pahlavan and Khalid Qarryzada
// Last modification date: change this to the last modification date or look very silly
#include "tm4c123gh6pm.h"
// ADC initialization function
// Input: none
// Output: none
void ADC_Init(void);
//------------ADC_In------------
// Busy-wait Analog to digital conversion
// Input: none
// Output: 12-bit result of ADC conversion
uint32_t ADC_In(void);
| 25.684211 | 87 | 0.713115 |
ed7b5561b2c46a73d0f0c37d324c6013c0bc66c3 | 14,859 | c | C | postgresql/src/backend/parser/parse_node.c | anjingbin/starccm | 70db48004aa20bbb82cc24de80802b40c7024eff | [
"BSD-3-Clause"
] | 2 | 2020-01-06T07:43:30.000Z | 2020-07-11T20:53:53.000Z | postgresql/src/backend/parser/parse_node.c | anjingbin/starccm | 70db48004aa20bbb82cc24de80802b40c7024eff | [
"BSD-3-Clause"
] | null | null | null | postgresql/src/backend/parser/parse_node.c | anjingbin/starccm | 70db48004aa20bbb82cc24de80802b40c7024eff | [
"BSD-3-Clause"
] | null | null | null | /*-------------------------------------------------------------------------
*
* parse_node.c
* various routines that make nodes for query plans
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* $Header: /home/hjcvs/OB-CCM-1.0/postgresql/src/backend/parser/parse_node.c,v 1.1 2003/12/30 00:06:07 AnJingBin Exp $
*
*-------------------------------------------------------------------------
*/
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include "postgres.h"
#include "access/heapam.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_type.h"
#include "fmgr.h"
#include "nodes/makefuncs.h"
#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
#include "parser/parse_node.h"
#include "parser/parse_oper.h"
#include "parser/parse_relation.h"
#include "parser/parse_target.h"
#include "parser/parse_type.h"
#include "utils/builtins.h"
#include "utils/varbit.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
static bool fitsInFloat(Value *value);
/* make_parsestate()
* Allocate and initialize a new ParseState.
* The CALLER is responsible for freeing the ParseState* returned.
*/
ParseState *
make_parsestate(ParseState *parentParseState)
{
ParseState *pstate;
pstate = palloc(sizeof(ParseState));
MemSet(pstate, 0, sizeof(ParseState));
pstate->parentParseState = parentParseState;
pstate->p_last_resno = 1;
return pstate;
}
/* make_operand()
* Ensure argument type match by forcing conversion of constants.
*/
Node *
make_operand(char *opname,
Node *tree,
Oid orig_typeId,
Oid target_typeId)
{
Node *result;
if (tree != NULL)
{
/* must coerce? */
if (target_typeId != orig_typeId)
result = coerce_type(NULL, tree, orig_typeId, target_typeId, -1);
else
result = tree;
}
else
{
/* otherwise, this is a NULL value */
result = (Node *) makeNullConst(target_typeId);
}
return result;
} /* make_operand() */
/* make_op()
* Operator construction.
*
* Transform operator expression ensuring type compatibility.
* This is where some type conversion happens.
*/
Expr *
make_op(char *opname, Node *ltree, Node *rtree)
{
Oid ltypeId,
rtypeId;
Operator tup;
Form_pg_operator opform;
Oper *newop;
Node *left,
*right;
Expr *result;
ltypeId = (ltree == NULL) ? UNKNOWNOID : exprType(ltree);
rtypeId = (rtree == NULL) ? UNKNOWNOID : exprType(rtree);
/* right operator? */
if (rtree == NULL)
{
tup = right_oper(opname, ltypeId);
opform = (Form_pg_operator) GETSTRUCT(tup);
left = make_operand(opname, ltree, ltypeId, opform->oprleft);
right = NULL;
}
/* left operator? */
else if (ltree == NULL)
{
tup = left_oper(opname, rtypeId);
opform = (Form_pg_operator) GETSTRUCT(tup);
right = make_operand(opname, rtree, rtypeId, opform->oprright);
left = NULL;
}
/* otherwise, binary operator */
else
{
tup = oper(opname, ltypeId, rtypeId, false);
opform = (Form_pg_operator) GETSTRUCT(tup);
left = make_operand(opname, ltree, ltypeId, opform->oprleft);
right = make_operand(opname, rtree, rtypeId, opform->oprright);
}
newop = makeOper(oprid(tup), /* opno */
InvalidOid, /* opid */
opform->oprresult); /* operator result type */
result = makeNode(Expr);
result->typeOid = opform->oprresult;
result->opType = OP_EXPR;
result->oper = (Node *) newop;
if (!left)
result->args = makeList1(right);
else if (!right)
result->args = makeList1(left);
else
result->args = makeList2(left, right);
ReleaseSysCache(tup);
return result;
} /* make_op() */
/*
* make_var
* Build a Var node for an attribute identified by RTE and attrno
*/
Var *
make_var(ParseState *pstate, RangeTblEntry *rte, int attrno)
{
int vnum,
sublevels_up;
Oid vartypeid = 0;
int32 type_mod = 0;
vnum = RTERangeTablePosn(pstate, rte, &sublevels_up);
if (rte->relid != InvalidOid)
{
/* Plain relation RTE --- get the attribute's type info */
HeapTuple tp;
Form_pg_attribute att_tup;
tp = SearchSysCache(ATTNUM,
ObjectIdGetDatum(rte->relid),
Int16GetDatum(attrno),
0, 0);
/* this shouldn't happen... */
if (!HeapTupleIsValid(tp))
elog(ERROR, "Relation %s does not have attribute %d",
rte->relname, attrno);
att_tup = (Form_pg_attribute) GETSTRUCT(tp);
vartypeid = att_tup->atttypid;
type_mod = att_tup->atttypmod;
ReleaseSysCache(tp);
}
else
{
/* Subselect RTE --- get type info from subselect's tlist */
List *tlistitem;
foreach(tlistitem, rte->subquery->targetList)
{
TargetEntry *te = (TargetEntry *) lfirst(tlistitem);
if (te->resdom->resjunk || te->resdom->resno != attrno)
continue;
vartypeid = te->resdom->restype;
type_mod = te->resdom->restypmod;
break;
}
/* falling off end of list shouldn't happen... */
if (tlistitem == NIL)
elog(ERROR, "Subquery %s does not have attribute %d",
rte->eref->relname, attrno);
}
return makeVar(vnum, attrno, vartypeid, type_mod, sublevels_up);
}
/*
* transformArraySubscripts()
* Transform array subscripting. This is used for both
* array fetch and array assignment.
*
* In an array fetch, we are given a source array value and we produce an
* expression that represents the result of extracting a single array element
* or an array slice.
*
* In an array assignment, we are given a destination array value plus a
* source value that is to be assigned to a single element or a slice of
* that array. We produce an expression that represents the new array value
* with the source data inserted into the right part of the array.
*
* pstate Parse state
* arrayBase Already-transformed expression for the array as a whole
* (may be NULL if we are handling an INSERT)
* arrayType OID of array's datatype
* indirection Untransformed list of subscripts (must not be NIL)
* forceSlice If true, treat subscript as array slice in all cases
* assignFrom NULL for array fetch, else transformed expression for source.
*/
ArrayRef *
transformArraySubscripts(ParseState *pstate,
Node *arrayBase,
Oid arrayType,
List *indirection,
bool forceSlice,
Node *assignFrom)
{
Oid elementType,
resultType;
HeapTuple type_tuple_array,
type_tuple_element;
Form_pg_type type_struct_array,
type_struct_element;
bool isSlice = forceSlice;
List *upperIndexpr = NIL;
List *lowerIndexpr = NIL;
List *idx;
ArrayRef *aref;
/* Get the type tuple for the array */
type_tuple_array = SearchSysCache(TYPEOID,
ObjectIdGetDatum(arrayType),
0, 0, 0);
if (!HeapTupleIsValid(type_tuple_array))
elog(ERROR, "transformArraySubscripts: Cache lookup failed for array type %u",
arrayType);
type_struct_array = (Form_pg_type) GETSTRUCT(type_tuple_array);
elementType = type_struct_array->typelem;
if (elementType == InvalidOid)
elog(ERROR, "transformArraySubscripts: type %s is not an array",
NameStr(type_struct_array->typname));
/* Get the type tuple for the array element type */
type_tuple_element = SearchSysCache(TYPEOID,
ObjectIdGetDatum(elementType),
0, 0, 0);
if (!HeapTupleIsValid(type_tuple_element))
elog(ERROR, "transformArraySubscripts: Cache lookup failed for array element type %u",
elementType);
type_struct_element = (Form_pg_type) GETSTRUCT(type_tuple_element);
/*
* A list containing only single subscripts refers to a single array
* element. If any of the items are double subscripts (lower:upper),
* then the subscript expression means an array slice operation. In
* this case, we supply a default lower bound of 1 for any items that
* contain only a single subscript. The forceSlice parameter forces us
* to treat the operation as a slice, even if no lower bounds are
* mentioned. Otherwise, we have to prescan the indirection list to
* see if there are any double subscripts.
*/
if (!isSlice)
{
foreach(idx, indirection)
{
A_Indices *ai = (A_Indices *) lfirst(idx);
if (ai->lidx != NULL)
{
isSlice = true;
break;
}
}
}
/*
* The type represented by the subscript expression is the element
* type if we are fetching a single element, but it is the same as the
* array type if we are fetching a slice or storing.
*/
if (isSlice || assignFrom != NULL)
resultType = arrayType;
else
resultType = elementType;
/*
* Transform the subscript expressions.
*/
foreach(idx, indirection)
{
A_Indices *ai = (A_Indices *) lfirst(idx);
Node *subexpr;
if (isSlice)
{
if (ai->lidx)
{
subexpr = transformExpr(pstate, ai->lidx, EXPR_COLUMN_FIRST);
/* If it's not int4 already, try to coerce */
subexpr = CoerceTargetExpr(pstate, subexpr, exprType(subexpr),
INT4OID, -1);
if (subexpr == NULL)
elog(ERROR, "array index expressions must be integers");
}
else
{
/* Make a constant 1 */
subexpr = (Node *) makeConst(INT4OID,
sizeof(int32),
Int32GetDatum(1),
false,
true, /* pass by value */
false,
false);
}
lowerIndexpr = lappend(lowerIndexpr, subexpr);
}
subexpr = transformExpr(pstate, ai->uidx, EXPR_COLUMN_FIRST);
/* If it's not int4 already, try to coerce */
subexpr = CoerceTargetExpr(pstate, subexpr, exprType(subexpr),
INT4OID, -1);
if (subexpr == NULL)
elog(ERROR, "array index expressions must be integers");
upperIndexpr = lappend(upperIndexpr, subexpr);
}
/*
* If doing an array store, coerce the source value to the right type.
*/
if (assignFrom != NULL)
{
Oid typesource = exprType(assignFrom);
Oid typeneeded = isSlice ? arrayType : elementType;
if (typesource != InvalidOid)
{
if (typesource != typeneeded)
{
/* XXX fixme: need to get the array's atttypmod? */
assignFrom = CoerceTargetExpr(pstate, assignFrom,
typesource, typeneeded,
-1);
if (assignFrom == NULL)
elog(ERROR, "Array assignment requires type '%s'"
" but expression is of type '%s'"
"\n\tYou will need to rewrite or cast the expression",
format_type_be(typeneeded),
format_type_be(typesource));
}
}
}
/*
* Ready to build the ArrayRef node.
*/
aref = makeNode(ArrayRef);
aref->refattrlength = type_struct_array->typlen;
aref->refelemlength = type_struct_element->typlen;
aref->refelemtype = resultType; /* XXX should save element type
* too */
aref->refelembyval = type_struct_element->typbyval;
aref->refupperindexpr = upperIndexpr;
aref->reflowerindexpr = lowerIndexpr;
aref->refexpr = arrayBase;
aref->refassgnexpr = assignFrom;
ReleaseSysCache(type_tuple_array);
ReleaseSysCache(type_tuple_element);
return aref;
}
/*
* make_const
*
* Convert a Value node (as returned by the grammar) to a Const node
* of the "natural" type for the constant. Note that this routine is
* only used when there is no explicit cast for the constant, so we
* have to guess what type is wanted.
*
* For string literals we produce a constant of type UNKNOWN ---- whose
* representation is the same as text, but it indicates to later type
* resolution that we're not sure that it should be considered text.
* Explicit "NULL" constants are also typed as UNKNOWN.
*
* For integers and floats we produce int4, float8, or numeric depending
* on the value of the number. XXX In some cases it would be nice to take
* context into account when determining the type to convert to, but in
* other cases we can't delay the type choice. One possibility is to invent
* a dummy type "UNKNOWNNUMERIC" that's treated similarly to UNKNOWN;
* that would allow us to do the right thing in examples like a simple
* INSERT INTO table (numericcolumn) VALUES (1.234), since we wouldn't
* have to resolve the unknown type until we knew the destination column
* type. On the other hand UNKNOWN has considerable problems of its own.
* We would not like "SELECT 1.2 + 3.4" to claim it can't choose a type.
*/
Const *
make_const(Value *value)
{
Datum val;
Oid typeid;
int typelen;
bool typebyval;
Const *con;
switch (nodeTag(value))
{
case T_Integer:
val = Int32GetDatum(intVal(value));
typeid = INT4OID;
typelen = sizeof(int32);
typebyval = true;
break;
case T_Float:
if (fitsInFloat(value))
{
val = Float8GetDatum(floatVal(value));
typeid = FLOAT8OID;
typelen = sizeof(float8);
typebyval = false; /* XXX might change someday */
}
else
{
val = DirectFunctionCall3(numeric_in,
CStringGetDatum(strVal(value)),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(-1));
typeid = NUMERICOID;
typelen = -1; /* variable len */
typebyval = false;
}
break;
case T_String:
val = DirectFunctionCall1(textin, CStringGetDatum(strVal(value)));
typeid = UNKNOWNOID; /* will be coerced later */
typelen = -1; /* variable len */
typebyval = false;
break;
case T_BitString:
val = DirectFunctionCall3(bit_in,
CStringGetDatum(strVal(value)),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(-1));
typeid = BITOID;
typelen = -1;
typebyval = false;
break;
default:
elog(NOTICE, "make_const: unknown type %d", nodeTag(value));
/* FALLTHROUGH */
case T_Null:
/* return a null const */
con = makeConst(UNKNOWNOID,
-1,
(Datum) NULL,
true,
false,
false,
false);
return con;
}
con = makeConst(typeid,
typelen,
val,
false,
typebyval,
false, /* not a set */
false); /* not coerced */
return con;
}
/*
* Decide whether a T_Float value fits in float8, or must be treated as
* type "numeric". We check the number of digits and check for overflow/
* underflow. (With standard compilation options, Postgres' NUMERIC type
* can handle decimal exponents up to 1000, considerably more than most
* implementations of float8, so this is a sensible test.)
*/
static bool
fitsInFloat(Value *value)
{
const char *ptr;
int ndigits;
char *endptr;
/*
* Count digits, ignoring leading zeroes (but not trailing zeroes).
* DBL_DIG is the maximum safe number of digits for "double".
*/
ptr = strVal(value);
while (*ptr == '+' || *ptr == '-' || *ptr == '0' || *ptr == '.')
ptr++;
ndigits = 0;
for (; *ptr; ptr++)
{
if (isdigit((unsigned char) *ptr))
ndigits++;
else if (*ptr == 'e' || *ptr == 'E')
break; /* don't count digits in exponent */
}
if (ndigits > DBL_DIG)
return false;
/*
* Use strtod() to check for overflow/underflow.
*/
errno = 0;
(void) strtod(strVal(value), &endptr);
if (*endptr != '\0' || errno != 0)
return false;
return true;
}
| 26.8213 | 121 | 0.668215 |
e69eb295116ec9a0f73c7220edc70c7756639bcb | 370 | h | C | LQ_TC26xB_LIBtasking/src/AppSw/Tricore/APP/pa_CommonLib/pa_PID.h | ActivePeter/tc264_tasking_car | 1f5426c5fdaa291c07c8b53f1c2fabfd6c7cf0b9 | [
"MIT"
] | 10 | 2020-08-03T08:59:25.000Z | 2022-03-23T03:03:39.000Z | LQ_TC26xB_LIBtasking/src/AppSw/Tricore/APP/pa_CommonLib/pa_PID.h | ActivePeter/tc264_tasking_car | 1f5426c5fdaa291c07c8b53f1c2fabfd6c7cf0b9 | [
"MIT"
] | 1 | 2020-08-21T04:06:28.000Z | 2020-08-21T04:06:28.000Z | LQ_TC26xB_LIBtasking/src/AppSw/Tricore/APP/pa_CommonLib/pa_PID.h | ActivePeter/tc264_tasking_car | 1f5426c5fdaa291c07c8b53f1c2fabfd6c7cf0b9 | [
"MIT"
] | 3 | 2020-08-21T03:49:50.000Z | 2022-03-18T13:59:07.000Z | #ifndef __pa_PID_H_
#define __pa_PID_H_
#define Max_iSum 1000
class pa_PID
{
public:
pa_PID();
pa_PID(float kp1,float ki1,float kd1);
float calcPid(float err);
void setPid(float kp,float ki,float kd);
void setMax(float max1);
float kp;
float ki;
float kd;
float iSum=0;//积分项
private:
float max=-1;
float lastErr=0;
};
#endif | 16.818182 | 44 | 0.656757 |
902255dcfb1184d37fe3f7b4b3d1bbecdbb41364 | 1,006 | c | C | libft/ft_isspace_bonus.c | iamfantaser/fractol | 94d41855b3d566c58ff95b44deb4432feb452346 | [
"MIT"
] | null | null | null | libft/ft_isspace_bonus.c | iamfantaser/fractol | 94d41855b3d566c58ff95b44deb4432feb452346 | [
"MIT"
] | null | null | null | libft/ft_isspace_bonus.c | iamfantaser/fractol | 94d41855b3d566c58ff95b44deb4432feb452346 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isspace.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dwulfe <dwulfe@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/17 20:06:40 by dwulfe #+# #+# */
/* Updated: 2021/04/22 12:25:25 by dwulfe ### ########.fr */
/* */
/* ************************************************************************** */
int ft_isspace(int c)
{
if (c == 32 || (c > 8 && c < 14))
return (1);
else
return (0);
}
| 50.3 | 81 | 0.140159 |
c24e1bcc3447a032c38179d778461065dea85b39 | 217 | h | C | Example/TTMMOO3/TTMMOOViewController.h | tanglimei/TTMMOO3 | 0b6926570527f808f8614a147ee5f983673eec16 | [
"MIT"
] | null | null | null | Example/TTMMOO3/TTMMOOViewController.h | tanglimei/TTMMOO3 | 0b6926570527f808f8614a147ee5f983673eec16 | [
"MIT"
] | null | null | null | Example/TTMMOO3/TTMMOOViewController.h | tanglimei/TTMMOO3 | 0b6926570527f808f8614a147ee5f983673eec16 | [
"MIT"
] | null | null | null | //
// TTMMOOViewController.h
// TTMMOO3
//
// Created by tanglimei on 12/02/2015.
// Copyright (c) 2015 tanglimei. All rights reserved.
//
@import UIKit;
@interface TTMMOOViewController : UIViewController
@end
| 15.5 | 54 | 0.714286 |
b0a4e440951b24fd21b3a4c268e712fef67d8015 | 703 | h | C | source/Core/Log/Policies/Linux/Linux_IdeWritePolicy.h | Scylardor/Monocle2 | ff894b7065c589a1cba8093468ab9fae26db41e0 | [
"BSD-3-Clause"
] | null | null | null | source/Core/Log/Policies/Linux/Linux_IdeWritePolicy.h | Scylardor/Monocle2 | ff894b7065c589a1cba8093468ab9fae26db41e0 | [
"BSD-3-Clause"
] | null | null | null | source/Core/Log/Policies/Linux/Linux_IdeWritePolicy.h | Scylardor/Monocle2 | ff894b7065c589a1cba8093468ab9fae26db41e0 | [
"BSD-3-Clause"
] | null | null | null | #ifndef MOE_LINUX_IDE_WRITE_POLICY_H_
#define MOE_LINUX_IDE_WRITE_POLICY_H_
// LINUX version of IdeWritePolicy
// A write policy supposed to map to an IDE's output window.
// On Linux, IdeWritePolicy basically acts as a wrapper around the error fd (std::cerr).
#ifdef MOE_STD_SUPPORT
#include <string>
#include "Core/Preprocessor/moeDLLVisibility.h"
#include "Core/Log/Policies/OutStreamWritePolicy.h"
namespace moe
{
class IdeWritePolicy
{
public:
MOE_DLL_API IdeWritePolicy();
MOE_DLL_API void Write(const std::string& message);
private:
moe::OutStreamWritePolicy m_redirection;
};
}
#endif // MOE_STD_SUPPORT
#endif // MOE_LINUX_IDE_WRITE_POLICY_H_ | 25.107143 | 88 | 0.748222 |
1138aa34cd65455f83e188d7b673a98a42efa266 | 688 | h | C | B_field_3D_model.h | bjbuckman/galprop_bb_ | 076b168f7475b3ba9fb198b6ec2df7be66b1763c | [
"MIT"
] | null | null | null | B_field_3D_model.h | bjbuckman/galprop_bb_ | 076b168f7475b3ba9fb198b6ec2df7be66b1763c | [
"MIT"
] | null | null | null | B_field_3D_model.h | bjbuckman/galprop_bb_ | 076b168f7475b3ba9fb198b6ec2df7be66b1763c | [
"MIT"
] | null | null | null | #include <vector>
#include <string>
void B_field_3D_model
(const std::string &name, const std::vector<double> ¶meters,
double x, double y, double z,
int options,
double &Breg, double &Bregx, double &Bregy, double &Bregz,
double &Bran, double &Branx, double &Brany, double &Branz,
int debug=0);
double Bperp(double x,double y,double z, double Bx,double By,double Bz, double x0,double y0,double z0);
double B_field_3D_model_tot
(const std::string &name, const std::vector<double> ¶meters,
double x, double y, double z,
int debug=0 );
double B_field_3D_model_tot
(const std::string &name, const std::vector<double> ¶meters,
double R, double z,
int debug=0 );
| 24.571429 | 103 | 0.728198 |
da3dd9b8c8ebafd2f2a1787932e08cff175bcc9c | 611 | h | C | src/layer.h | jonpas/FERI-SymRec | 2432cdfe253582134593baade274cf47c5f6539e | [
"MIT"
] | null | null | null | src/layer.h | jonpas/FERI-SymRec | 2432cdfe253582134593baade274cf47c5f6539e | [
"MIT"
] | null | null | null | src/layer.h | jonpas/FERI-SymRec | 2432cdfe253582134593baade274cf47c5f6539e | [
"MIT"
] | null | null | null | #pragma once
#include <QList>
using DataRow = QList<double>;
using Data = QList<DataRow>;
class Layer {
public:
Layer(uint inputs, uint neurons, QString activation = "sigmoid", QList<double> weightRandBound = {-0.5, 0.5}, QList<double> biasBounds = {0.0, 0.0});
DataRow activate(DataRow data);
double applyActivation(double x);
double applyActivationDerivative(double x);
// Modified by Neural Network
Data weights;
DataRow errors;
DataRow deltas;
DataRow lastActivation;
private:
uint _inputs;
uint _neurons;
DataRow _biases;
QString _activation;
};
| 20.366667 | 153 | 0.690671 |
fd670dbe8eb52bbeefa89a56b3ed23eb95e41027 | 1,979 | h | C | include/sys/list.h | alnyan/ygg-kernel-amd64 | 12ef80d2901eb3fd7a17f1aea3eed328c74d6e56 | [
"MIT"
] | 15 | 2019-11-16T04:33:32.000Z | 2022-01-09T23:30:06.000Z | include/sys/list.h | xclinux/ygg-kernel-amd64 | 12ef80d2901eb3fd7a17f1aea3eed328c74d6e56 | [
"MIT"
] | null | null | null | include/sys/list.h | xclinux/ygg-kernel-amd64 | 12ef80d2901eb3fd7a17f1aea3eed328c74d6e56 | [
"MIT"
] | 2 | 2020-10-18T16:58:24.000Z | 2022-01-07T14:26:42.000Z | #pragma once
struct list_head {
struct list_head *prev, *next;
};
#define LIST_HEAD(name) \
struct list_head name = { &name, &name }
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
#define list_entry(link, type, member) ({ \
const typeof (((type *) 0)->member) *__memb = (link); \
(type *) ((char *) __memb - offsetof(type, member)); \
})
#define list_next_entry(pos, member) \
list_entry((pos)->member.next, typeof(*(pos)), member)
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
static inline void list_head_init(struct list_head *list) {
list->next = list;
list->prev = list;
}
static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next) {
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
static inline void list_add(struct list_head *new, struct list_head *head) {
__list_add(new, head, head->next);
}
static inline void list_add_tail(struct list_head *new, struct list_head *head) {
__list_add(new, head->prev, head);
}
static inline void __list_del(struct list_head *prev, struct list_head *next) {
next->prev = prev;
prev->next = next;
}
static inline void list_del(struct list_head *entry) {
__list_del(entry->prev, entry->next);
}
static inline int list_empty(const struct list_head *head) {
return head->next == head;
}
static inline void list_del_init(struct list_head *entry) {
__list_del(entry->prev, entry->next);
list_head_init(entry);
}
| 27.486111 | 81 | 0.645781 |
0a319aeb20bee57b58fee08dc2c21af904644d7a | 276 | h | C | proxy/RequestParser.h | kayzhang/HTTP-caching-proxy | 9a5be2e049add5e32c57d75a03f53246dffd40e0 | [
"MIT"
] | null | null | null | proxy/RequestParser.h | kayzhang/HTTP-caching-proxy | 9a5be2e049add5e32c57d75a03f53246dffd40e0 | [
"MIT"
] | null | null | null | proxy/RequestParser.h | kayzhang/HTTP-caching-proxy | 9a5be2e049add5e32c57d75a03f53246dffd40e0 | [
"MIT"
] | null | null | null | #ifndef REQUEST_PARSER_H
#define REQUEST_PARSER_H
#include <cstdio>
#include <string>
#include "Request.h"
class RequestParser
{
public:
// Parser a request string to a Request object
static void parse_request(const char * buf, int buf_len, Request & req);
};
#endif
| 16.235294 | 74 | 0.742754 |
0a4aa6e1475939d987c9e11532b2e2d53afb4348 | 7,120 | c | C | deps/pmdk/src/libpmem/memops_generic.c | kimleeju/xdp_redis | 52eaf9da59e5b9ddb009a7874791cdbe6ce9ba06 | [
"BSD-3-Clause"
] | 60 | 2020-04-28T08:15:07.000Z | 2022-03-08T10:35:15.000Z | deps/pmdk/src/libpmem/memops_generic.c | kimleeju/xdp_redis | 52eaf9da59e5b9ddb009a7874791cdbe6ce9ba06 | [
"BSD-3-Clause"
] | 66 | 2020-09-03T23:40:48.000Z | 2022-03-07T20:34:52.000Z | deps/pmdk/src/libpmem/memops_generic.c | kimleeju/xdp_redis | 52eaf9da59e5b9ddb009a7874791cdbe6ce9ba06 | [
"BSD-3-Clause"
] | 13 | 2019-11-02T06:30:36.000Z | 2022-01-26T01:56:42.000Z | /*
* Copyright 2018, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* memops_generic.c -- architecture-independent memmove & memset fallback
*
* This fallback is needed to fulfill guarantee that pmem_mem[cpy|set|move]
* will use at least 8-byte stores (for 8-byte aligned buffers and sizes),
* even when accelerated implementation is missing or disabled.
* This guarantee is needed to maintain correctness eg in pmemobj.
* Libc may do the same, but this behavior is not documented, so we can't rely
* on that.
*/
#include <stddef.h>
#include "out.h"
#include "pmem.h"
#include "libpmem.h"
#include "util.h"
/*
* cpy64 -- (internal) copy 64 bytes from src to dst
*/
static force_inline void
cpy64(uint64_t *dst, const uint64_t *src)
{
/*
* We use atomics here just to be sure compiler will not split stores.
* Order of stores doesn't matter.
*/
uint64_t tmp[8];
util_atomic_load_explicit64(&src[0], &tmp[0], memory_order_relaxed);
util_atomic_load_explicit64(&src[1], &tmp[1], memory_order_relaxed);
util_atomic_load_explicit64(&src[2], &tmp[2], memory_order_relaxed);
util_atomic_load_explicit64(&src[3], &tmp[3], memory_order_relaxed);
util_atomic_load_explicit64(&src[4], &tmp[4], memory_order_relaxed);
util_atomic_load_explicit64(&src[5], &tmp[5], memory_order_relaxed);
util_atomic_load_explicit64(&src[6], &tmp[6], memory_order_relaxed);
util_atomic_load_explicit64(&src[7], &tmp[7], memory_order_relaxed);
util_atomic_store_explicit64(&dst[0], tmp[0], memory_order_relaxed);
util_atomic_store_explicit64(&dst[1], tmp[1], memory_order_relaxed);
util_atomic_store_explicit64(&dst[2], tmp[2], memory_order_relaxed);
util_atomic_store_explicit64(&dst[3], tmp[3], memory_order_relaxed);
util_atomic_store_explicit64(&dst[4], tmp[4], memory_order_relaxed);
util_atomic_store_explicit64(&dst[5], tmp[5], memory_order_relaxed);
util_atomic_store_explicit64(&dst[6], tmp[6], memory_order_relaxed);
util_atomic_store_explicit64(&dst[7], tmp[7], memory_order_relaxed);
}
/*
* cpy8 -- (internal) copy 8 bytes from src to dst
*/
static force_inline void
cpy8(uint64_t *dst, const uint64_t *src)
{
uint64_t tmp;
util_atomic_load_explicit64(src, &tmp, memory_order_relaxed);
util_atomic_store_explicit64(dst, tmp, memory_order_relaxed);
}
/*
* store8 -- (internal) store 8 bytes
*/
static force_inline void
store8(uint64_t *dst, uint64_t c)
{
util_atomic_store_explicit64(dst, c, memory_order_relaxed);
}
/*
* memmove_nodrain_generic -- generic memmove to pmem without hw drain
*/
void *
memmove_nodrain_generic(void *dst, const void *src, size_t len,
unsigned flags)
{
LOG(15, "pmemdest %p src %p len %zu flags 0x%x", dst, src, len,
flags);
char *cdst = dst;
const char *csrc = src;
size_t remaining;
(void) flags;
if ((uintptr_t)cdst - (uintptr_t)csrc >= len) {
size_t cnt = (uint64_t)cdst & 7;
if (cnt > 0) {
cnt = 8 - cnt;
if (cnt > len)
cnt = len;
for (size_t i = 0; i < cnt; ++i)
cdst[i] = csrc[i];
pmem_flush_flags(cdst, cnt, flags);
cdst += cnt;
csrc += cnt;
len -= cnt;
}
uint64_t *dst8 = (uint64_t *)cdst;
const uint64_t *src8 = (const uint64_t *)csrc;
while (len >= 64) {
cpy64(dst8, src8);
pmem_flush_flags(dst8, 64, flags);
len -= 64;
dst8 += 8;
src8 += 8;
}
remaining = len;
while (len >= 8) {
cpy8(dst8, src8);
len -= 8;
dst8++;
src8++;
}
cdst = (char *)dst8;
csrc = (const char *)src8;
for (size_t i = 0; i < len; ++i)
*cdst++ = *csrc++;
if (remaining)
pmem_flush_flags(cdst - remaining, remaining, flags);
} else {
cdst += len;
csrc += len;
size_t cnt = (uint64_t)cdst & 7;
if (cnt > 0) {
if (cnt > len)
cnt = len;
cdst -= cnt;
csrc -= cnt;
len -= cnt;
for (size_t i = cnt; i > 0; --i)
cdst[i - 1] = csrc[i - 1];
pmem_flush_flags(cdst, cnt, flags);
}
uint64_t *dst8 = (uint64_t *)cdst;
const uint64_t *src8 = (const uint64_t *)csrc;
while (len >= 64) {
dst8 -= 8;
src8 -= 8;
cpy64(dst8, src8);
pmem_flush_flags(dst8, 64, flags);
len -= 64;
}
remaining = len;
while (len >= 8) {
--dst8;
--src8;
cpy8(dst8, src8);
len -= 8;
}
cdst = (char *)dst8;
csrc = (const char *)src8;
for (size_t i = len; i > 0; --i)
*--cdst = *--csrc;
if (remaining)
pmem_flush_flags(cdst, remaining, flags);
}
return dst;
}
/*
* memset_nodrain_generic -- generic memset to pmem without hw drain
*/
void *
memset_nodrain_generic(void *dst, int c, size_t len, unsigned flags)
{
LOG(15, "pmemdest %p c 0x%x len %zu flags 0x%x", dst, c, len,
flags);
(void) flags;
char *cdst = dst;
size_t cnt = (uint64_t)cdst & 7;
if (cnt > 0) {
cnt = 8 - cnt;
if (cnt > len)
cnt = len;
for (size_t i = 0; i < cnt; ++i)
cdst[i] = (char)c;
pmem_flush_flags(cdst, cnt, flags);
cdst += cnt;
len -= cnt;
}
uint64_t *dst8 = (uint64_t *)cdst;
uint64_t u = (unsigned char)c;
uint64_t tmp = (u << 56) | (u << 48) | (u << 40) | (u << 32) |
(u << 24) | (u << 16) | (u << 8) | u;
while (len >= 64) {
store8(&dst8[0], tmp);
store8(&dst8[1], tmp);
store8(&dst8[2], tmp);
store8(&dst8[3], tmp);
store8(&dst8[4], tmp);
store8(&dst8[5], tmp);
store8(&dst8[6], tmp);
store8(&dst8[7], tmp);
pmem_flush_flags(dst8, 64, flags);
len -= 64;
dst8 += 8;
}
size_t remaining = len;
while (len >= 8) {
store8(dst8, tmp);
len -= 8;
dst8++;
}
cdst = (char *)dst8;
for (size_t i = 0; i < len; ++i)
*cdst++ = (char)c;
if (remaining)
pmem_flush_flags(cdst - remaining, remaining, flags);
return dst;
}
| 26.176471 | 78 | 0.66573 |
d375c6917b8bd31e7ce8bc4906f8e4729471803a | 609 | h | C | src/views/watchwindow/LColorSelectButton.h | lotusczp/Lobster | ceb5ec720fdbbd5eddba5eeccc2f875a62d4332e | [
"Apache-2.0",
"MIT"
] | 6 | 2021-01-30T00:06:22.000Z | 2022-02-16T08:20:09.000Z | src/views/watchwindow/LColorSelectButton.h | lotusczp/Lobster | ceb5ec720fdbbd5eddba5eeccc2f875a62d4332e | [
"Apache-2.0",
"MIT"
] | null | null | null | src/views/watchwindow/LColorSelectButton.h | lotusczp/Lobster | ceb5ec720fdbbd5eddba5eeccc2f875a62d4332e | [
"Apache-2.0",
"MIT"
] | 1 | 2021-08-11T05:19:11.000Z | 2021-08-11T05:19:11.000Z | #ifndef LCOLORSELECTBUTTON_H
#define LCOLORSELECTBUTTON_H
#include <QWidget>
namespace Ui {
class LColorSelectButton;
}
class LColorSelectButton : public QWidget
{
Q_OBJECT
public:
explicit LColorSelectButton(QWidget *parent = 0);
~LColorSelectButton();
void setColor(const QColor &a_rColor);
const QColor& getColor() const;
signals:
void colorChanged(QColor color);
private slots:
void on_pushButton_clicked();
private:
void applyColorChange();
private:
Ui::LColorSelectButton *ui;
QColor m_color; //!< color of the button
};
#endif // LCOLORSELECTBUTTON_H
| 16.459459 | 53 | 0.729064 |
d3230111a9b4657fcb65fcba9b61591a9e7a2959 | 2,609 | h | C | include/socket.h | jvstech/jvs-netlib | 80374521bc67135397e01d38b90ae65fa39adb10 | [
"MIT"
] | null | null | null | include/socket.h | jvstech/jvs-netlib | 80374521bc67135397e01d38b90ae65fa39adb10 | [
"MIT"
] | null | null | null | include/socket.h | jvstech/jvs-netlib | 80374521bc67135397e01d38b90ae65fa39adb10 | [
"MIT"
] | null | null | null | //!
//! @file socket.h
//!
#if !defined(JVS_NETLIB_SOCKET_H_)
#define JVS_NETLIB_SOCKET_H_
#include <cstddef>
#include <cstdint>
#include <memory>
#include <optional>
#include <ostream>
#include <string>
#include <utility>
#include "error.h"
#include "ip_address.h"
#include "ip_end_point.h"
#include "socket_errors.h"
namespace jvs::net
{
//!
//! @class Socket
//!
//! Provides an error-checked wrapper around BSD and Winsock interfaces.
//!
class Socket final
{
public:
enum class Transport
{
Tcp,
Udp,
Raw
};
Socket(Socket&&);
~Socket();
Socket(net::IpAddress::Family addressFamily, Transport transport);
// Bound/listening endpoint.
IpEndPoint local() const noexcept;
// Remote endpoint of the communication, if any.
const std::optional<IpEndPoint>& remote() const noexcept;
// Handle/context/file descriptor of the native socket resource.
std::intptr_t descriptor() const noexcept;
Expected<Socket> accept() noexcept;
// Number of bytes available for reading from the socket.
Expected<std::size_t> available() noexcept;
Expected<IpEndPoint> bind(IpEndPoint localEndPoint) noexcept;
Expected<IpEndPoint> bind(IpAddress localAddress, NetworkU16 localPort) noexcept;
Expected<IpEndPoint> bind(IpAddress localAddress) noexcept;
Expected<IpEndPoint> bind(NetworkU16 localPort) noexcept;
Expected<IpEndPoint> bind() noexcept;
int close() noexcept;
Expected<IpEndPoint> connect(IpEndPoint remoteEndPoint) noexcept;
Expected<IpEndPoint> connect(IpAddress remoteAddress, NetworkU16 remotePort) noexcept;
Expected<IpEndPoint> listen() noexcept;
Expected<IpEndPoint> listen(int backlog) noexcept;
Expected<std::size_t> recv(void* buffer, std::size_t length, int flags) noexcept;
Expected<std::size_t> recv(void* buffer, std::size_t length) noexcept;
Expected<std::pair<std::size_t, IpEndPoint>> recvfrom(
void* buffer, std::size_t length, int flags) noexcept;
Expected<std::pair<std::size_t, IpEndPoint>> recvfrom(void* buffer, std::size_t length) noexcept;
Expected<std::size_t> send(const void* buffer, std::size_t length, int flags) noexcept;
Expected<std::size_t> send(const void* buffer, std::size_t length) noexcept;
Expected<std::size_t> sendto(
const void* buffer, std::size_t length, int flags, const IpEndPoint& remoteEp) noexcept;
Expected<std::size_t> sendto(
const void* buffer, std::size_t length, const IpEndPoint& remoteEp) noexcept;
private:
class SocketImpl;
std::unique_ptr<SocketImpl> impl_;
Socket(SocketImpl* impl);
};
} // namespace jvs::net
#endif // !JVS_NETLIB_SOCKET_H_
| 28.053763 | 99 | 0.738597 |
877610fd2e5021fc8a50f546c7237ff9a7294207 | 1,625 | h | C | butano/hw/3rd_party/libtonc/include/tonc.h | laqieer/butano | 986ec1d235922fbe7acafa7564a911085d3a9c6e | [
"Zlib"
] | 571 | 2020-11-09T10:23:43.000Z | 2022-03-29T05:03:53.000Z | butano/hw/3rd_party/libtonc/include/tonc.h | laqieer/butano | 986ec1d235922fbe7acafa7564a911085d3a9c6e | [
"Zlib"
] | 18 | 2020-11-12T03:17:48.000Z | 2022-02-16T12:25:14.000Z | butano/hw/3rd_party/libtonc/include/tonc.h | laqieer/butano | 986ec1d235922fbe7acafa7564a911085d3a9c6e | [
"Zlib"
] | 23 | 2020-11-12T01:23:02.000Z | 2022-02-06T11:24:15.000Z | //
// Main tonc header
//
//! \file tonc.h
//! \author J Vijn
//! \date 20060508 - 20080825
//
// === NOTES ===
#ifndef TONC_MAIN
#define TONC_MAIN
#ifdef __cplusplus
extern "C" {
#endif
#include "tonc_types.h"
#include "tonc_memmap.h"
#include "tonc_memdef.h"
#include "tonc_bios.h"
#include "tonc_core.h"
#include "tonc_input.h"
#include "tonc_irq.h"
#include "tonc_math.h"
#include "tonc_oam.h"
#include "tonc_tte.h"
#include "tonc_video.h"
#include "tonc_surface.h"
#include "tonc_nocash.h"
#ifdef __cplusplus
};
#endif
// --- Doxygen modules: ---
/*! \defgroup grpBios Bios Calls */
/*! \defgroup grpCore Core */
/*! \defgroup grpDma DMA */
/*! \defgroup grpInput Input */
/*! \defgroup grpIrq Interrupt */
/*! \defgroup grpMath Math */
/*! \defgroup grpMemmap Memory Map */
/*! \defgroup grpAudio Sound */
/*! \defgroup grpTTE Tonc Text Engine */
/*! \defgroup grpText Old Text */
/*! \defgroup grpTimer Timer */
/*! \defgroup grpVideo Video */
/*! \mainpage Tonclib 1.4 (20080825)
<p>
Tonclib is the library accompanying the set of GBA tutorials known
as <a href="http://www.coranac.com/tonc/">Tonc</a> Initially, it
was just a handful of macros and functions for dealing with the
GBA hardware: the memory map and its bits, affine transformation
code and things like that. More recently, more general items
have been added like tonccpy() and toncset(), the TSurface system
and TTE. All these items should provide a firm basis on which to
build GBA software.
</p>
*/
#endif // TONC_MAIN
| 23.214286 | 69 | 0.650462 |
e1749af5f75b1cf19d7a438a237c16e15c16fefc | 2,478 | h | C | src/lib/entropy/unix_procs/unix_procs.h | el-forkorama/botan | 4ad555977b03cb92dfac0b87a00febe4d8e7ff5e | [
"BSD-2-Clause"
] | null | null | null | src/lib/entropy/unix_procs/unix_procs.h | el-forkorama/botan | 4ad555977b03cb92dfac0b87a00febe4d8e7ff5e | [
"BSD-2-Clause"
] | null | null | null | src/lib/entropy/unix_procs/unix_procs.h | el-forkorama/botan | 4ad555977b03cb92dfac0b87a00febe4d8e7ff5e | [
"BSD-2-Clause"
] | null | null | null | /*
* Unix EntropySource
* (C) 1999-2009,2013 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_ENTROPY_SRC_UNIX_H__
#define BOTAN_ENTROPY_SRC_UNIX_H__
#include <botan/entropy_src.h>
#include <vector>
#include <mutex>
namespace Botan {
/**
* Entropy source for generic Unix. Runs various programs trying to
* gather data hard for a remote attacker to guess. Probably not too
* effective against local attackers as they can sample from the same
* distribution.
*/
class Unix_EntropySource final : public Entropy_Source
{
public:
std::string name() const override { return "unix_procs"; }
void poll(Entropy_Accumulator& accum) override;
/**
* @param trusted_paths is a list of directories that are assumed
* to contain only 'safe' binaries. If an attacker can write
* an executable to one of these directories then we will
* run arbitrary code.
*/
Unix_EntropySource(const std::vector<std::string>& trusted_paths,
size_t concurrent_processes = 0);
private:
static std::vector<std::vector<std::string>> get_default_sources();
class Unix_Process
{
public:
int fd() const { return m_fd; }
void spawn(const std::vector<std::string>& args);
void shutdown();
Unix_Process() {}
Unix_Process(const std::vector<std::string>& args) { spawn(args); }
~Unix_Process() { shutdown(); }
Unix_Process(Unix_Process&& other)
{
std::swap(m_fd, other.m_fd);
std::swap(m_pid, other.m_pid);
}
Unix_Process(const Unix_Process&) = delete;
Unix_Process& operator=(const Unix_Process&) = delete;
private:
int m_fd = -1;
int m_pid = -1;
};
const std::vector<std::string>& next_source();
std::mutex m_mutex;
const std::vector<std::string> m_trusted_paths;
const size_t m_concurrent;
std::vector<std::vector<std::string>> m_sources;
size_t m_sources_idx = 0;
std::vector<Unix_Process> m_procs;
secure_vector<byte> m_buf;
};
class UnixProcessInfo_EntropySource final : public Entropy_Source
{
public:
std::string name() const override { return "proc_info"; }
void poll(Entropy_Accumulator& accum) override;
};
}
#endif
| 26.934783 | 79 | 0.622276 |
91cb22198e3888a3260f2f8615bb397944ae6c30 | 409 | h | C | Categories/NSString+WhiteSpace_Utility.h | mzgaljic/mzgaljic | 9918a92bcfae140fcb52d849423b06624acc502b | [
"MIT"
] | 7 | 2017-05-10T15:46:28.000Z | 2021-04-26T04:25:01.000Z | Categories/NSString+WhiteSpace_Utility.h | mzgaljic/mzgaljic | 9918a92bcfae140fcb52d849423b06624acc502b | [
"MIT"
] | 1 | 2017-08-07T15:44:12.000Z | 2017-08-10T01:48:13.000Z | Categories/NSString+WhiteSpace_Utility.h | mzgaljic/mzgaljic | 9918a92bcfae140fcb52d849423b06624acc502b | [
"MIT"
] | null | null | null | //
// NSString+WhiteSpace_Utility.h
// Free Music Library
//
// Created by Mark Zgaljic on 7/25/14.
// Copyright (c) 2014 Mark Zgaljic. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (WhiteSpace_Utility)
/**Trims 'heading' and 'trailing' whitespace in a string.
Whitespace between meaningful characters is NOT removed.*/
- (NSString *)removeIrrelevantWhitespace;
@end
| 22.722222 | 59 | 0.738386 |
4c358ee9536893c5f45a8f5c038c2404a64b50d1 | 1,095 | h | C | include/input.h | mistydemeo/supergameherm | e410b55906ebb8093ead2758c2dffb82dfa88d29 | [
"BSD-3-Clause"
] | null | null | null | include/input.h | mistydemeo/supergameherm | e410b55906ebb8093ead2758c2dffb82dfa88d29 | [
"BSD-3-Clause"
] | null | null | null | include/input.h | mistydemeo/supergameherm | e410b55906ebb8093ead2758c2dffb82dfa88d29 | [
"BSD-3-Clause"
] | null | null | null | #ifndef __INPUT_H_
#define __INPUT_H_
#include "config.h" // macros, uint[XX]_t
#include "typedefs.h" // typedefs
#define RAW_INPUT_P10 0x1
#define RAW_INPUT_P11 0x2
#define RAW_INPUT_P12 0x4
#define RAW_INPUT_P13 0x8
// Columns set
#define RAW_INPUT_P14 0x10
#define RAW_INPUT_P15 0x20
typedef enum
{
INPUT_NONE = 0,
INPUT_RIGHT = (RAW_INPUT_P10 | RAW_INPUT_P14),
INPUT_LEFT = (RAW_INPUT_P11 | RAW_INPUT_P14),
INPUT_UP = (RAW_INPUT_P12 | RAW_INPUT_P14),
INPUT_DOWN = (RAW_INPUT_P13 | RAW_INPUT_P14),
INPUT_A = (RAW_INPUT_P10 | RAW_INPUT_P15),
INPUT_B = (RAW_INPUT_P11 | RAW_INPUT_P15),
INPUT_SELECT = (RAW_INPUT_P12 | RAW_INPUT_P15),
INPUT_START = (RAW_INPUT_P13 | RAW_INPUT_P15),
} input_key;
struct input_state_t
{
uint8_t col; /*! P14 and P15 */
uint8_t row; /*! P10 through P13 */
uint8_t key_col; /*! Current col pressed */
uint8_t key_row; /*! Current row pressed */
};
uint8_t joypad_read(emu_state *restrict, uint16_t);
void joypad_write(emu_state *restrict, uint16_t, uint8_t);
void joypad_signal(emu_state *restrict, input_key, bool);
#endif /*!__INPUT_H_*/
| 23.804348 | 58 | 0.747945 |
483db67c7637555950d0dc6dd1203ec0b8788ec3 | 4,796 | c | C | test/bst_test.c | libgeneprog/libgeneprog | 2a0105403000f2fe2e2f825b64862777d7ee9132 | [
"BSD-3-Clause"
] | 1 | 2020-08-03T02:40:58.000Z | 2020-08-03T02:40:58.000Z | test/bst_test.c | libgeneprog/libgeneprog | 2a0105403000f2fe2e2f825b64862777d7ee9132 | [
"BSD-3-Clause"
] | 7 | 2019-01-18T15:55:32.000Z | 2019-02-08T16:37:38.000Z | test/bst_test.c | libgeneprog/libgeneprog | 2a0105403000f2fe2e2f825b64862777d7ee9132 | [
"BSD-3-Clause"
] | null | null | null | // SPDX-License-Identifier: BSD-3-Clause
#include "bst_test.h"
#include <stdlib.h>
#include "CUnit/CUnit.h"
#include "CUnit/Basic.h"
#include "bst-data.h"
#include "gene.h"
int _init_bst_suite(void) { return 0; }
int _clean_bst_suite(void) { return 0; }
int gp_test_bst_setup_suite(void)
{
CU_pSuite pSuite = NULL;
/* add a suite to the registry */
pSuite = CU_add_suite("bst_test_suite",
_init_bst_suite,
_clean_bst_suite);
if (pSuite == NULL) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */
if (CU_add_test(pSuite, "_gp_test_bst_alloc", _gp_test_bst_alloc) ==
NULL ||
CU_add_test(pSuite, "_gp_test_bst_clone", _gp_test_bst_clone) ==
NULL ||
CU_add_test(pSuite, "_gp_test_bst_node_debug_json",
_gp_test_bst_node_debug_json) ==
NULL) {
CU_cleanup_registry();
return CU_get_error();
}
return CU_get_error();
}
void _gp_test_bst_alloc(void)
{
struct GP_Gene *gene = GP_BST_alloc(1, 2, 3);
// It should not be null:
CU_ASSERT_PTR_NOT_NULL_FATAL(gene);
// It should not have null functions:
CU_ASSERT_PTR_NOT_NULL(gene->evaluate);
CU_ASSERT_PTR_NOT_NULL(gene->clone);
CU_ASSERT_PTR_NOT_NULL(gene->mutate);
CU_ASSERT_PTR_NOT_NULL(gene->free);
CU_ASSERT_PTR_NOT_NULL(gene->as_debug_json);
// It should have set the proper gene type:
CU_ASSERT_EQUAL(gene->geneType, GeneTypeBST);
// It should not have null data:
CU_ASSERT_PTR_NOT_NULL_FATAL(gene->data);
// Get our data for more testing:
struct GP_BSTData *bstdata = (struct GP_BSTData *)(gene->data);
// It should set the variables:
CU_ASSERT_EQUAL(bstdata->num_inputs, 1);
CU_ASSERT_EQUAL(bstdata->depth, 2);
CU_ASSERT_EQUAL(bstdata->num_outputs, 3);
}
void _gp_test_bst_clone_node(struct GP_BSTNode *original,
struct GP_BSTNode *clone)
{
// If the original is NULL, assert the clone is NULL and return:
if (original == NULL) {
CU_ASSERT_PTR_NULL(clone);
} else {
// The original is not NULL.
// The clone must not be null:
CU_ASSERT_PTR_NOT_NULL_FATAL(clone);
// Check the addresses. They *must* be different:
CU_ASSERT_PTR_NOT_EQUAL(clone, original);
// Node type & params must be the same:
CU_ASSERT_EQUAL(clone->nodeType, original->nodeType);
CU_ASSERT_EQUAL(clone->nodeParams, original->nodeParams);
// Check the children:
_gp_test_bst_clone_node(original->leftNode, clone->leftNode);
_gp_test_bst_clone_node(original->rightNode, clone->rightNode);
}
}
void _gp_test_bst_clone(void)
{
// Make a gene and randomize it:
struct GP_Gene *original_gene = GP_BST_alloc(1, 2, 3);
GP_BST_randomize(original_gene);
// Make a clone:
struct GP_Gene *clone_gene = GP_BST_clone(original_gene);
// It should not be null:
CU_ASSERT_PTR_NOT_NULL_FATAL(clone_gene);
// It should not have null functions:
CU_ASSERT_PTR_NOT_NULL(clone_gene->evaluate);
CU_ASSERT_PTR_NOT_NULL(clone_gene->clone);
CU_ASSERT_PTR_NOT_NULL(clone_gene->mutate);
CU_ASSERT_PTR_NOT_NULL(clone_gene->free);
// It should not have null data:
CU_ASSERT_PTR_NOT_NULL_FATAL(clone_gene->data);
// It shouldn't be the same as the original gene:
CU_ASSERT_PTR_NOT_EQUAL(clone_gene, original_gene);
// Get the data of both for using:
struct GP_BSTData *original_data;
struct GP_BSTData *clone_data;
original_data = (struct GP_BSTData *)(original_gene->data);
clone_data = (struct GP_BSTData *)(clone_gene->data);
// It'd shouldn't have the same data address as the original gene
CU_ASSERT_PTR_NOT_EQUAL(clone_data, original_data);
// Make sure the non-tree is the same
CU_ASSERT_EQUAL(clone_data->num_inputs, original_data->num_inputs);
CU_ASSERT_EQUAL(clone_data->num_outputs, original_data->num_outputs);
CU_ASSERT_EQUAL(clone_data->depth, original_data->depth);
// Make sure the output_nodes are set:
CU_ASSERT_PTR_NOT_NULL_FATAL(clone_data->output_nodes);
// Now the fun part.
// We go through each tree, and confirm:
// 1) The node addressed in the clone are NOT NULL
// if the original is not null
// 2) The node addresses in the clone don't match the original
// 3) The node VALUES in the clone match the original
// 4) Repeat for each child of the node
for (int idx = 0; idx < original_data->num_outputs; idx++) {
_gp_test_bst_clone_node(original_data->output_nodes[idx],
clone_data->output_nodes[idx]);
}
}
void _gp_test_bst_node_debug_json(void)
{
// 1) Test a null node:
char *nullNodeData = GP_BST_node_debug_json(NULL);
CU_ASSERT_STRING_EQUAL(nullNodeData, "null");
struct GP_BSTNode *node;
node = (struct GP_BSTNode *)malloc(sizeof(struct GP_BSTNode));
node->nodeType = BSTNodeTypeInput;
char *nodeData = GP_BST_node_debug_json(node);
CU_ASSERT_PTR_NOT_NULL_FATAL(nodeData);
// TODO: Check for elements of that node
}
| 29.243902 | 70 | 0.741243 |
73cc9db52d8142c2936f9246f339f1787421ffad | 1,547 | h | C | library/src/main/cpp/faceTracker/FaceTrackerWrapper.h | 1463836/android-gpuimage-plus | ad00886e8947e69548814eb457e39985aebea103 | [
"MIT"
] | null | null | null | library/src/main/cpp/faceTracker/FaceTrackerWrapper.h | 1463836/android-gpuimage-plus | ad00886e8947e69548814eb457e39985aebea103 | [
"MIT"
] | null | null | null | library/src/main/cpp/faceTracker/FaceTrackerWrapper.h | 1463836/android-gpuimage-plus | ad00886e8947e69548814eb457e39985aebea103 | [
"MIT"
] | null | null | null | /*
* cgeFaceTrackerWrapper.h
*
* Created on: 2016-2-17
* Author: Wang Yang
* Mail: admin@wysaid.org
*/
#ifndef _cgeFaceTrackerWrapper_h_
#define _cgeFaceTrackerWrapper_h_
#include <jni.h>
#include "FaceTracker.h"
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL
Java_org_wysaid_nativePort_CGEFaceTracker_nativeSetupTracker
(JNIEnv
*, jclass, jstring, jstring, jstring);
JNIEXPORT jlong
JNICALL Java_org_wysaid_nativePort_CGEFaceTracker_nativeCreateFaceTracker
(JNIEnv *, jobject);
JNIEXPORT void JNICALL
Java_org_wysaid_nativePort_CGEFaceTracker_nativeRelease
(JNIEnv
*, jobject, jlong);
JNIEXPORT jfloatArray
JNICALL Java_org_wysaid_nativePort_CGEFaceTracker_nativeDetectFaceWithSimpleResult
(JNIEnv *, jobject, jlong, jobject, jboolean);
JNIEXPORT jboolean
JNICALL Java_org_wysaid_nativePort_CGEFaceTracker_nativeDetectFaceWithBuffer
(JNIEnv *, jobject, jlong, jobject, jint, jint, jint, jint, jobject);
#ifdef __cplusplus
}
#endif
namespace CGE {
class CGEFaceTrackerWrapper {
public:
CGEFaceTrackerWrapper();
~CGEFaceTrackerWrapper();
bool trackContinuousImage(void *buffer, int w, int h, int channel, int stride);
bool
trackImage(void *buffer, int w, int h, int stride, int channel, bool drawFeature = false);
inline CGEFaceTracker *getTracker() { return m_tracker; }
private:
CGEFaceTracker *m_tracker;
cv::Mat m_cacheImage;
bool m_hasFace;
};
}
#endif | 23.089552 | 98 | 0.722689 |
bc07d4cc1bd9e9ea75a722d051c9e198b6d117df | 558 | h | C | src/qt/znumwnodeconfigdialog.h | newcopycoin/newcopycoin | c87619a749fb115674fdd72c9a6a501492bffefe | [
"MIT"
] | null | null | null | src/qt/znumwnodeconfigdialog.h | newcopycoin/newcopycoin | c87619a749fb115674fdd72c9a6a501492bffefe | [
"MIT"
] | null | null | null | src/qt/znumwnodeconfigdialog.h | newcopycoin/newcopycoin | c87619a749fb115674fdd72c9a6a501492bffefe | [
"MIT"
] | null | null | null | #ifndef ZNUMWNODECONFIGDIALOG_H
#define ZNUMWNODECONFIGDIALOG_H
#include <QDialog>
namespace Ui {
class ZnumwNodeConfigDialog;
}
QT_BEGIN_NAMESPACE
class QModelIndex;
QT_END_NAMESPACE
/** Dialog showing transaction details. */
class ZnumwNodeConfigDialog : public QDialog
{
Q_OBJECT
public:
explicit ZnumwNodeConfigDialog(QWidget *parent = 0, QString nodeAddress = "123.456.789.123:58786", QString privkey="MASTERNODEPRIVKEY");
~ZnumwNodeConfigDialog();
private:
Ui::ZnumwNodeConfigDialog *ui;
};
#endif // ZNUMWNODECONFIGDIALOG_H
| 19.928571 | 140 | 0.775986 |
86b8d5ddb82500fda8780d632aa9cd1f0d7211d0 | 1,426 | h | C | 3rd_party/nek5000_parRSB/src/gencon/gencon.h | Nek5000/nekrs | 7a55f459cd9b42129d0d3312dac8dd614cdb50d0 | [
"BSD-3-Clause"
] | 2 | 2021-09-07T03:00:53.000Z | 2021-12-06T18:08:27.000Z | 3rd_party/nek5000_parRSB/src/gencon/gencon.h | yhaomin2007/nekRS | a416c98ed00d48d1bd9722dcca781a1859fc37f4 | [
"BSD-3-Clause"
] | 2 | 2021-06-27T02:07:27.000Z | 2021-08-24T04:47:42.000Z | 3rd_party/nek5000_parRSB/src/gencon/gencon.h | yhaomin2007/nekRS | a416c98ed00d48d1bd9722dcca781a1859fc37f4 | [
"BSD-3-Clause"
] | null | null | null | #ifndef _GENMAP_GENCON_H_
#define _GENMAP_GENCON_H_
#include <genmap.h>
/* Upper bound for number of dimensions */
#define GC_MAX_DIM 3
/* Boundary condition types */
#define GC_PERIODIC "P "
/* Upper bounds for elements */
#define GC_MAX_FACES 6
#define GC_MAX_VERTICES 8
#define GC_MAX_NEIGHBORS 3
/* Upper bounds for faces */
#define GC_MAX_FACE_VERTICES 4
typedef struct Point_private *Point;
typedef struct Element_private *Element;
typedef struct Boundary_private *BoundaryFace;
typedef struct Mesh_private *Mesh;
extern int NEIGHBOR_MAP[GC_MAX_VERTICES][GC_MAX_NEIGHBORS];
extern int PRE_TO_SYM_VERTEX[GC_MAX_VERTICES];
extern int PRE_TO_SYM_FACE[GC_MAX_FACES];
/* Mesh */
int mesh_init(Mesh *m, int nel, int nDim);
void get_vertex_ids(long long **ids, Mesh m);
void get_vertex_coordinates(double **coords, Mesh m);
int get_bcs(unsigned int *nbcs, long long **bcs, Mesh m);
int get_mesh_dim(Mesh m);
int get_mesh_nel(Mesh m);
int mesh_free(Mesh m);
/* Connectivity */
int findMinNeighborDistance(Mesh mesh);
int findUniqueVertices(Mesh mesh, struct comm *c, GenmapScalar tol, int verbose,
buffer *bfr);
int faceCheck(Mesh mesh, struct comm *c, buffer *bfr);
int elementCheck(Mesh mesh, struct comm *c, buffer *bfr);
int setGlobalID(Mesh mesh, struct comm *c);
int sendBack(Mesh mesh, struct comm *c, buffer *bfr);
int matchPeriodicFaces(Mesh mesh, struct comm *c, buffer *bfr);
#endif
| 29.102041 | 80 | 0.759467 |
06b9d2f63818987fc8485047e43e6d38f67fd8bc | 3,226 | h | C | HandleUtils/ObjectDirectoryEntry.h | GabberBaby/sandbox-attacksurface-analysis-tools | 2c6010febf92a473ac84f3333bb9c28bbc69bc6a | [
"Apache-2.0"
] | null | null | null | HandleUtils/ObjectDirectoryEntry.h | GabberBaby/sandbox-attacksurface-analysis-tools | 2c6010febf92a473ac84f3333bb9c28bbc69bc6a | [
"Apache-2.0"
] | null | null | null | HandleUtils/ObjectDirectoryEntry.h | GabberBaby/sandbox-attacksurface-analysis-tools | 2c6010febf92a473ac84f3333bb9c28bbc69bc6a | [
"Apache-2.0"
] | 2 | 2021-08-18T05:16:11.000Z | 2021-09-25T04:15:49.000Z | // Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http ://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "ObjectDirectory.h"
namespace HandleUtils {
ref class ObjectDirectory;
public ref class ObjectDirectoryEntry : public System::IComparable < ObjectDirectoryEntry^ >
{
private:
System::String^ _name;
System::String^ _type_name;
ObjectDirectory^ _directory;
System::String^ _sddl;
array<unsigned char>^ _sd;
void ReadSecurityDescriptor();
void ReadStringSecurityDescriptor();
internal:
ObjectDirectoryEntry(System::String^ name, System::String^ type_name, ObjectDirectory^ directory)
{
_name = name;
_type_name = type_name;
_directory = directory;
}
public:
property System::String^ ObjectName {
System::String^ get() {
return _name;
}
}
property System::String^ TypeName {
System::String^ get() {
return _type_name;
}
}
property bool IsDirectory {
bool get() {
return _type_name->Equals("Directory", System::StringComparison::OrdinalIgnoreCase);
}
}
property bool IsSymlink {
bool get() {
return _type_name->Equals("SymbolicLink", System::StringComparison::OrdinalIgnoreCase);
}
}
property ObjectDirectory^ ParentDirectory {
ObjectDirectory^ get() {
return _directory;
}
}
property System::String^ FullPath {
System::String^ get() {
System::String^ base_name = _directory->FullPath->TrimEnd(gcnew array<wchar_t>(1) { '\\' });
return System::String::Format("{0}\\{1}", base_name, _name);
}
}
property array<unsigned char>^ SecurityDescriptor {
array<unsigned char>^ get() {
if (_sd == nullptr)
{
ReadSecurityDescriptor();
}
return _sd;
}
}
property System::String^ StringSecurityDescriptor {
System::String^ get() {
if (_sddl == nullptr)
{
ReadStringSecurityDescriptor();
}
return _sddl;
}
}
int GetHashCode() override
{
return _name->GetHashCode() ^ _type_name->GetHashCode();
}
bool Equals(Object^ other) override
{
if (other->GetType() == ObjectDirectoryEntry::typeid)
{
ObjectDirectoryEntry^ other_entry = safe_cast<ObjectDirectoryEntry^>(other);
return _name->Equals(other_entry->_name) && _type_name->Equals(other_entry->_type_name);
}
else
{
return false;
}
}
virtual int CompareTo(ObjectDirectoryEntry^ other)
{
int ret = this->_name->CompareTo(other->_name);
if (ret == 0)
{
ret = this->_type_name->CompareTo(other->_type_name);
}
return ret;
}
};
} | 23.547445 | 100 | 0.646931 |
e5d4e6411db3cb3335cb5f01d3c0ab0d75931493 | 473 | h | C | UnitTests/dotNetInstallerToolsLibUnitTests/ImageUtilUnitTests.h | baSSiLL/dotnetinstaller | 2a983649553cd322f674fe06685f0c1d47f638b2 | [
"MIT"
] | null | null | null | UnitTests/dotNetInstallerToolsLibUnitTests/ImageUtilUnitTests.h | baSSiLL/dotnetinstaller | 2a983649553cd322f674fe06685f0c1d47f638b2 | [
"MIT"
] | null | null | null | UnitTests/dotNetInstallerToolsLibUnitTests/ImageUtilUnitTests.h | baSSiLL/dotnetinstaller | 2a983649553cd322f674fe06685f0c1d47f638b2 | [
"MIT"
] | 1 | 2020-04-30T10:25:58.000Z | 2020-04-30T10:25:58.000Z | #pragma once
namespace DVLib
{
namespace UnitTests
{
class ImageUtilUnitTests : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE( ImageUtilUnitTests );
CPPUNIT_TEST(testLoadBitmapFromFile);
CPPUNIT_TEST(testLoadBitmapFromBuffer);
CPPUNIT_TEST(testLoadBitmapFromResource);
CPPUNIT_TEST_SUITE_END();
public:
void testLoadBitmapFromFile();
void testLoadBitmapFromBuffer();
void testLoadBitmapFromResource();
};
}
}
| 22.52381 | 61 | 0.735729 |
66805d33f85740afd653d6be7717bae6f7dfd00e | 6,627 | c | C | sys/src/cmd/dict/robert.c | Plan9-Archive/plan9-2e | ce6d0434246216e848babe4f56919dc28981ad04 | [
"MIT"
] | 1 | 2021-03-23T22:40:43.000Z | 2021-03-23T22:40:43.000Z | sys/src/cmd/dict/robert.c | Plan9-Archive/plan9-2e | ce6d0434246216e848babe4f56919dc28981ad04 | [
"MIT"
] | null | null | null | sys/src/cmd/dict/robert.c | Plan9-Archive/plan9-2e | ce6d0434246216e848babe4f56919dc28981ad04 | [
"MIT"
] | 1 | 2021-12-21T06:19:58.000Z | 2021-12-21T06:19:58.000Z | #include <u.h>
#include <libc.h>
#include <bio.h>
#include "dict.h"
/*
* Robert Électronique.
*/
enum
{
CIT = MULTIE+1, /* citation ptr followed by long int and ascii label */
BROM, /* bold roman */
ITON, /* start italic */
ROM, /* roman */
SYM, /* symbol font? */
HEL, /* helvetica */
BHEL, /* helvetica bold */
SMALL, /* smaller? */
ITOFF, /* end italic */
SUP, /* following character is superscript */
SUB /* following character is subscript */
};
static Rune intab[256] = {
/*0*/ /*1*/ /*2*/ /*3*/ /*4*/ /*5*/ /*6*/ /*7*/
/*00*/ NONE, L'☺', L'☻', L'♥', L'♦', L'♣', L'♠', L'•',
0x25d8, L'ʘ', L'\n', L'♂', L'♀', L'♪', 0x266b, L'※',
/*10*/ L'⇨', L'⇦', L'↕', L'‼', L'¶', L'§', L'⁃', L'↨',
L'↑', L'↓', L'→', L'←', L'⌙', L'↔', 0x25b4, 0x25be,
/*20*/ L' ', L'!', L'"', L'#', L'$', L'%', L'&', L''',
L'(', L')', L'*', L'+', L',', L'-', L'.', L'/',
/*30*/ L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7',
L'8', L'9', L':', L';', L'<', L'=', L'>', L'?',
/*40*/ L'@', L'A', L'B', L'C', L'D', L'E', L'F', L'G',
L'H', L'I', L'J', L'K', L'L', L'M', L'N', L'O',
/*50*/ L'P', L'Q', L'R', L'S', L'T', L'U', L'V', L'W',
L'X', L'Y', L'Z', L'[', L'\\', L']', L'^', L'_',
/*60*/ L'`', L'a', L'b', L'c', L'd', L'e', L'f', L'g',
L'h', L'i', L'j', L'k', L'l', L'm', L'n', L'o',
/*70*/ L'p', L'q', L'r', L's', L't', L'u', L'v', L'w',
L'x', L'y', L'z', L'{', L'|', L'}', L'~', L'',
/*80*/ L'Ç', L'ü', L'é', L'â', L'ä', L'à', L'å', L'ç',
L'ê', L'ë', L'è', L'ï', L'î', L'ì', L'Ä', L'Å',
/*90*/ L'É', L'æ', L'Æ', L'ô', L'ö', L'ò', L'û', L'ù',
L'ÿ', L'Ö', L'Ü', L'¢', L'£', L'¥', L'₧', L'ʃ',
/*a0*/ L'á', L'í', L'ó', L'ú', L'ñ', L'Ñ', L'ª', L'º',
L'¿', L'⌐', L'¬', L'½', L'¼', L'¡', L'«', L'»',
/*b0*/ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
/*c0*/ NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
CIT, BROM, NONE, ITON, ROM, SYM, HEL, BHEL,
/*d0*/ NONE, SMALL, ITOFF, SUP, SUB, NONE, NONE, NONE,
NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE,
/*e0*/ L'α', L'ß', L'γ', L'π', L'Σ', L'σ', L'µ', L'τ',
L'Φ', L'Θ', L'Ω', L'δ', L'∞', L'Ø', L'ε', L'∩',
/*f0*/ L'≡', L'±', L'≥', L'≤', L'⌠', L'⌡', L'÷', L'≈',
L'°', L'∙', L'·', L'√', L'ⁿ', L'²', L'∎', L' ',
};
static Rune suptab[] = {
['0'] L'⁰', ['1'] L'ⁱ', ['2'] L'', ['3'] L'',
['4'] L'⁴', ['5'] L'⁵', ['6'] L'⁶', ['7'] L'⁷',
['8'] L'⁸', ['9'] L'⁹', ['+'] L'⁺', ['-'] L'⁻',
['='] L'⁼', ['('] L'⁽', [')'] L'⁾', ['a'] L'ª',
['n'] L'ⁿ', ['o'] L'º'
};
static Rune subtab[] = {
['0'] L'₀', ['1'] L'₁', ['2'] L'₂', ['3'] L'₃',
['4'] L'₄', ['5'] L'₅', ['6'] L'₆', ['7'] L'₇',
['8'] L'₈', ['9'] L'₉', ['+'] L'₊', ['-'] L'₋',
['='] L'₌', ['('] L'₍', [')'] L'₎'
};
#define GSHORT(p) (((p)[0]<<8) | (p)[1])
#define GLONG(p) (((p)[0]<<24) | ((p)[1]<<16) | ((p)[2]<<8) | (p)[3])
static char cfile[] = "/lib/dict/robert/cits.rob";
static char dfile[] = "/lib/dict/robert/defs.rob";
static char efile[] = "/lib/dict/robert/etym.rob";
static char kfile[] = "/lib/dict/robert/_phon";
static Biobuf * cb;
static Biobuf * db;
static Biobuf * eb;
static Biobuf * Bouvrir(char*);
static void citation(int, int);
static void robertprintentry(Entry*, Entry*, int);
void
robertindexentry(Entry e, int cmd)
{
uchar *p = (uchar *)e.start;
long ea, el, da, dl, fa;
Entry def, etym;
ea = GLONG(&p[0]);
el = GSHORT(&p[4]);
da = GLONG(&p[6]);
dl = GSHORT(&p[10]);
fa = GLONG(&p[12]);
USED(fa);
if(db == 0)
db = Bouvrir(dfile);
def.start = malloc(dl+1);
def.end = def.start + dl;
def.doff = da;
Bseek(db, da, 0);
Bread(db, def.start, dl);
*def.end = 0;
if(cmd == 'h'){
robertprintentry(&def, 0, cmd);
}else{
if(eb == 0)
eb = Bouvrir(efile);
etym.start = malloc(el+1);
etym.end = etym.start + el;
etym.doff = ea;
Bseek(eb, ea, 0);
Bread(eb, etym.start, el);
*etym.end = 0;
robertprintentry(&def, &etym, cmd);
free(etym.start);
}
free(def.start);
}
static void
robertprintentry(Entry *def, Entry *etym, int cmd)
{
uchar *p, *pe;
Rune r; int c, n;
int baseline = 0;
int lineno = 0;
int cit = 0;
p = (uchar *)def->start;
pe = (uchar *)def->end;
while(p < pe){
if(cmd == 'r'){
outchar(*p++);
continue;
}
c = *p++;
switch(r = intab[c]){ /* assign = */
case BROM:
case ITON:
case ROM:
case SYM:
case HEL:
case BHEL:
case SMALL:
case ITOFF:
case NONE:
if(debug)
outprint("\\%.2ux", c);
baseline = 0;
break;
case SUP:
baseline = 1;
break;
case SUB:
baseline = -1;
break;
case CIT:
n = p[0] | (p[1]<<8) | (p[2]<<16) | (p[3]<<24);
p += 4;
if(debug)
outprint("[%d]", n);
while(*p == ' ' || ('0'<=*p && *p<='9') || *p == '.'){
if(debug)
outchar(*p);
++p;
}
++cit;
outnl(2);
citation(n, cmd);
baseline = 0;
break;
case '\n':
outnl(0);
baseline = 0;
++lineno;
break;
default:
if(baseline > 0 && r < nelem(suptab))
r = suptab[r];
else if(baseline < 0 && r < nelem(subtab))
r = subtab[r];
if(cit){
outchar('\n');
cit = 0;
}
outrune(r);
baseline = 0;
break;
}
if(r == '\n'){
if(cmd == 'h')
break;
if(lineno == 1 && etym)
robertprintentry(etym, 0, cmd);
}
}
outnl(0);
}
static void
citation(int addr, int cmd)
{
Entry cit;
if(cb == 0)
cb = Bouvrir(cfile);
Bseek(cb, addr, 0);
cit.start = Brdline(cb, 0xc8);
cit.end = cit.start + BLINELEN(cb) - 1;
cit.doff = addr;
*cit.end = 0;
robertprintentry(&cit, 0, cmd);
}
long
robertnextoff(long fromoff)
{
return (fromoff & ~15) + 16;
}
void
robertprintkey(void)
{
Biobuf *db;
char *l;
db = Bouvrir(kfile);
while(l = Brdline(db, '\n')) /* assign = */
Bwrite(bout, l, BLINELEN(db));
Bterm(db);
}
void
robertflexentry(Entry e, int cmd)
{
uchar *p, *pe;
Rune r; int c;
int lineno = 1;
p = (uchar *)e.start;
pe = (uchar *)e.end;
while(p < pe){
if(cmd == 'r'){
BPUTC(bout, *p++);
continue;
}
c = *p++;
r = intab[c];
if(r == '$')
r = '\n';
if(r == '\n'){
++lineno;
if(cmd == 'h' && lineno > 2)
break;
}
if(cmd == 'h' && lineno < 2)
continue;
if(r > MULTIE){
if(debug)
Bprint(bout, "\\%.2ux", c);
continue;
}
if(r < Runeself)
BPUTC(bout, r);
else
Bputrune(bout, r);
}
outnl(0);
}
long
robertnextflex(long fromoff)
{
int c;
if(Bseek(bdict, fromoff, 0) < 0)
return -1;
while((c = BGETC(bdict)) >= 0){
if(c == '$')
return Boffset(bdict);
}
return -1;
}
static Biobuf *
Bouvrir(char *fichier)
{
Biobuf *db;
db = Bopen(fichier, OREAD);
if(db == 0){
fprint(2, "%s: impossible d'ouvrir %s: %r\n", argv0, fichier);
exits("ouvrir");
}
return db;
}
| 21.172524 | 72 | 0.470801 |
bac767e55bc6e994580fd382edcd0e9f26d2d8ef | 226 | h | C | MVVM-Demo/DYPlayNews/Common/Tool/UIView+DYY.h | DefaultYuan/MVVMDemo | 2c53e7467ca4428fb12f37b05c26f0ce4b18c4b9 | [
"MIT"
] | 58 | 2017-05-31T16:05:39.000Z | 2018-02-26T06:24:40.000Z | MVVM-Demo/DYPlayNews/Common/Tool/UIView+DYY.h | AntBranch/MVVMDemo | 1fed95c99c8a3e8a295d0caec459c3f789e8fa2e | [
"MIT"
] | 1 | 2017-07-24T07:56:44.000Z | 2017-09-26T13:04:48.000Z | MVVM-Demo/DYPlayNews/Common/Tool/UIView+DYY.h | AntBranch/MVVMDemo | 1fed95c99c8a3e8a295d0caec459c3f789e8fa2e | [
"MIT"
] | 17 | 2017-06-05T01:30:52.000Z | 2017-10-11T09:33:53.000Z | //
// UIView+DYY.h
// DYPlayNews
//
// Created by 袁斌 on 2017/6/4.
// Copyright © 2017年 https://github.com/DefaultYuan . All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (DYY)
+ (NSString *) nibId;
@end
| 15.066667 | 75 | 0.646018 |
c94f2c56f078e4c60ed782d974602371c804a517 | 689 | h | C | train_model/FaceAlignment/globalregression.h | MichaelXin/face-alignment-cpp | 05ad23a51be51450b26ed46f01043f2577d53cdc | [
"MIT"
] | 41 | 2015-06-29T15:02:47.000Z | 2018-09-06T05:54:54.000Z | train_model/FaceAlignment/globalregression.h | MichaelXin/face-alignment-cpp | 05ad23a51be51450b26ed46f01043f2577d53cdc | [
"MIT"
] | 1 | 2015-10-17T18:03:16.000Z | 2015-10-17T18:03:16.000Z | train_model/FaceAlignment/globalregression.h | jwyang/face-alignment-cpp | 05ad23a51be51450b26ed46f01043f2577d53cdc | [
"MIT"
] | 41 | 2015-06-29T15:27:11.000Z | 2019-10-21T09:24:44.000Z | #ifndef GLOBALREGRESSION_H
#define GLOBALREGRESSION_H
#include "base.h"
#include "params.h"
#include "evaluate.h"
#include "utils.h"
#include "liblinear/linear.h"
class cRegression{
public:
cRegression(sTrainData* data, sParams* params);
cv::Mat_<double> GlobalRegression(const cv::Mat_<int>&binaryfeatures,int stage);
private:
cv::Mat_<double> __train_regressor(const cv::Mat_<double>& label_vec, const cv::SparseMat_<int>& instance_mat);
cv::Mat_<double> __train_regressor(const cv::Mat_<double>& label_vec, const cv::Mat_<int>& instance_mat);
private:
sTrainData* m_TrainData;
sParams* m_Params;
cUtils m_Utils;
cEvaluate* m_Evaluate;
};
#endif | 29.956522 | 113 | 0.732946 |
bfc01740ec9fda27943c93d895d4213e2fe81775 | 8,077 | c | C | phSolver/common/sympyr.c | Mopolino8/phasta | 797fc3d8fd047634092d01014b978420e15be66f | [
"BSD-3-Clause"
] | null | null | null | phSolver/common/sympyr.c | Mopolino8/phasta | 797fc3d8fd047634092d01014b978420e15be66f | [
"BSD-3-Clause"
] | null | null | null | phSolver/common/sympyr.c | Mopolino8/phasta | 797fc3d8fd047634092d01014b978420e15be66f | [
"BSD-3-Clause"
] | 1 | 2019-11-03T09:55:20.000Z | 2019-11-03T09:55:20.000Z | #include <stdlib.h>
#include <FCMangle.h>
#define sympyr FortranCInterface_GLOBAL_(sympyr, SYMPYR)
typedef double DARR4[4];
int pyrIntPnt(int,DARR4**,double **);
sympyr(int *n1, double pt[][4], double wt[], int *err)
{
double *lwt;
DARR4 *lpt;
int i,j;
*err = pyrIntPnt(*n1, &lpt, &lwt);
for(i=0; i < *n1; i++) {
wt[i] = lwt[i];
for(j=0; j <4; j++)
pt[i][j]=lpt[i][j];
}
}
/*$Id$*/
#include <stdio.h>
/* these are the rule 2 int points and weights */
#define mpt455 -0.455341801261479548
#define ppt455 0.455341801261479548
#define mpt577 -0.577350269189625764
#define ppt577 0.577350269189625764
#define mpt122 -0.122008467928146216
#define ppt122 0.122008467928146216
#define ppt622 0.622008467928146212
#define ppt044 0.0446581987385204510
/* these are the rule 3 int points and weights */
#define zero 0.0000000000000000
#define mpt687 -0.6872983346207417
#define ppt687 0.6872983346207417
#define mpt774 -0.7745966692414834
#define ppt774 0.7745966692414834
#define mpt387 -0.3872983346207416
#define ppt387 0.3872983346207416
#define mpt087 -0.08729833462074170
#define ppt087 0.08729833462074170
#define ppt134 0.1349962850858610
#define ppt215 0.2159940561373775
#define ppt345 0.3455904898198040
#define ppt068 0.06858710562414265
#define ppt109 0.1097393689986282
#define ppt175 0.1755829903978052
#define ppt002 0.002177926162424265
#define ppt003 0.003484681859878818
#define ppt005 0.005575490975806120
/* these are the rule 4 integration points */
/*NOT FIXED YET*/
#define Qp41 -0.801346029378026
#define Qp42 -0.316375532749811
#define Qp43 0.316375532749811
#define Qp44 0.801346029378026
#define Qp45 -0.8611363116
#define Qp46 -0.576953166749811
#define Qp47 -0.227784076803672
#define Qp48 0.227784076803672
#define Qp49 0.576953166749811
#define Qp410 -0.3399810436
#define Qp411 -0.284183144850188
#define Qp412 -0.112196966796327
#define Qp413 0.112196966796327
#define Qp414 0.284183144850188
#define Qp415 0.3399810436
#define Qp416 -0.0597902822219738
#define Qp417 -0.0236055108501886
#define Qp418 0.0236055108501886
#define Qp419 0.0597902822219738
#define Qp420 0.8611363116
/* Rule 1*/
static double rstw1[][4] = {
{ 0.0, 0.0, 0.0, 0.0 }
};
static double twt1[] = { 8.0000000 };
/* Rule 2*/
static double rstw8[][4] = {
{mpt455,mpt455,mpt577,0.0},
{ppt455,mpt455,mpt577,0.0},
{mpt455,ppt455,mpt577,0.0},
{ppt455,ppt455,mpt577,0.0},
{mpt122,mpt122,ppt577,0.0},
{ppt122,mpt122,ppt577,0.0},
{mpt122,ppt122,ppt577,0.0},
{ppt122,ppt122,ppt577,0.0}
};
static double twt8[] = {ppt622,ppt622,ppt622,ppt622,
ppt044,ppt044,ppt044,ppt044};
/* Rule 3*/
static double rstw27[][4] = {
{ mpt687, mpt687, mpt774, 0.0 },
{ zero, mpt687, mpt774, 0.0 },
{ ppt687, mpt687, mpt774, 0.0 },
{ mpt687, zero, mpt774, 0.0 },
{ zero, zero, mpt774, 0.0 },
{ ppt687, zero, mpt774, 0.0 },
{ mpt687, ppt687, mpt774, 0.0 },
{ zero, ppt687, mpt774, 0.0 },
{ ppt687, ppt687, mpt774, 0.0 },
{ mpt387, mpt387, zero, 0.0 },
{ zero, mpt387, zero, 0.0 },
{ ppt387, mpt387, zero, 0.0 },
{ mpt387, zero, zero, 0.0 },
{ zero, zero, zero, 0.0 },
{ ppt387, zero, zero, 0.0 },
{ mpt387, ppt387, zero, 0.0 },
{ zero, ppt387, zero, 0.0 },
{ ppt387, ppt387, zero, 0.0 },
{ mpt087, mpt087, ppt774, 0.0 },
{ zero, mpt087, ppt774, 0.0 },
{ ppt087, mpt087, ppt774, 0.0 },
{ mpt087, zero, ppt774, 0.0 },
{ zero, zero, ppt774, 0.0 },
{ ppt087, zero, ppt774, 0.0 },
{ mpt087, ppt087, ppt774, 0.0 },
{ zero, ppt087, ppt774, 0.0 },
{ ppt087, ppt087, ppt774, 0.0 }
};
static double twt27[] =
{0.1349962850858610, 0.2159940561373775, 0.1349962850858610,
0.2159940561373775, 0.3455904898198040, 0.2159940561373775,
0.1349962850858610, 0.2159940561373775, 0.1349962850858610,
0.06858710562414265, 0.1097393689986282, 0.06858710562414265,
0.1097393689986282, 0.1755829903978052, 0.1097393689986282,
0.06858710562414265, 0.1097393689986282, 0.06858710562414265,
0.002177926162424265, 0.003484681859878818, 0.002177926162424265,
0.003484681859878822, 0.005575490975806120, 0.003484681859878825,
0.002177926162424265, 0.003484681859878822, 0.002177926162424265};
/* Rule 4 */
static double rstw64[][4] = {
{ Qp41, Qp41, Qp45, 0.0 },
{ Qp42, Qp41, Qp45, 0.0 },
{ Qp43, Qp41, Qp45, 0.0 },
{ Qp44, Qp41, Qp45, 0.0 },
{ Qp41, Qp42, Qp45, 0.0 },
{ Qp42, Qp42, Qp45, 0.0 },
{ Qp43, Qp42, Qp45, 0.0 },
{ Qp44, Qp42, Qp45, 0.0 },
{ Qp41, Qp43, Qp45, 0.0 },
{ Qp42, Qp43, Qp45, 0.0 },
{ Qp43, Qp43, Qp45, 0.0 },
{ Qp44, Qp43, Qp45, 0.0 },
{ Qp41, Qp44, Qp45, 0.0 },
{ Qp42, Qp44, Qp45, 0.0 },
{ Qp43, Qp44, Qp45, 0.0 },
{ Qp44, Qp44, Qp45, 0.0 },
{ Qp46, Qp46, Qp410, 0.0 },
{ Qp47, Qp46, Qp410, 0.0 },
{ Qp48, Qp46, Qp410, 0.0 },
{ Qp49, Qp46, Qp410, 0.0 },
{ Qp46, Qp47, Qp410, 0.0 },
{ Qp47, Qp47, Qp410, 0.0 },
{ Qp48, Qp47, Qp410, 0.0 },
{ Qp49, Qp47, Qp410, 0.0 },
{ Qp46, Qp48, Qp410, 0.0 },
{ Qp47, Qp48, Qp410, 0.0 },
{ Qp48, Qp48, Qp410, 0.0 },
{ Qp49, Qp48, Qp410, 0.0 },
{ Qp46, Qp49, Qp410, 0.0 },
{ Qp47, Qp49, Qp410, 0.0 },
{ Qp48, Qp49, Qp410, 0.0 },
{ Qp49, Qp49, Qp410, 0.0 },
{ Qp411, Qp411, Qp415, 0.0 },
{ Qp412, Qp411, Qp415, 0.0 },
{ Qp413, Qp411, Qp415, 0.0 },
{ Qp414, Qp411, Qp415, 0.0 },
{ Qp411, Qp412, Qp415, 0.0 },
{ Qp412, Qp412, Qp415, 0.0 },
{ Qp413, Qp412, Qp415, 0.0 },
{ Qp414, Qp412, Qp415, 0.0 },
{ Qp411, Qp413, Qp415, 0.0 },
{ Qp412, Qp413, Qp415, 0.0 },
{ Qp413, Qp413, Qp415, 0.0 },
{ Qp414, Qp413, Qp415, 0.0 },
{ Qp411, Qp414, Qp415, 0.0 },
{ Qp412, Qp414, Qp415, 0.0 },
{ Qp413, Qp414, Qp415, 0.0 },
{ Qp414, Qp414, Qp415, 0.0 },
{ Qp416, Qp416, Qp420, 0.0 },
{ Qp417, Qp416, Qp420, 0.0 },
{ Qp418, Qp416, Qp420, 0.0 },
{ Qp419, Qp416, Qp420, 0.0 },
{ Qp416, Qp417, Qp420, 0.0 },
{ Qp417, Qp417, Qp420, 0.0 },
{ Qp418, Qp417, Qp420, 0.0 },
{ Qp419, Qp417, Qp420, 0.0 },
{ Qp416, Qp418, Qp420, 0.0 },
{ Qp417, Qp418, Qp420, 0.0 },
{ Qp418, Qp418, Qp420, 0.0 },
{ Qp419, Qp418, Qp420, 0.0 },
{ Qp416, Qp419, Qp420, 0.0 },
{ Qp417, Qp419, Qp420, 0.0 },
{ Qp418, Qp419, Qp420, 0.0 },
{ Qp419, Qp419, Qp420, 0.0 }
};
#ifdef __cplusplus
extern "C" {
#endif
int pyrIntPnt(int nint, DARR4 **bcord, double **wt)
{
int retval = 1;
int i,j,k,l;
DARR4 *rstw;
double *twt;
/* Rule 4 & 5*/
double bp5[]={-0.9061798459,-0.5384693101,0,0.5384693101,0.9061798459};
double bw4[]={0.3478548446,0.6521451548,0.6521451548,0.3478548446};
double bw5[]={0.2369268850,0.4786286708,0.5019607843,0.4786286708,0.2369268850};
if( nint == 1){ *bcord = rstw1; *wt = twt1;}
else if( nint == 8 ){*bcord = rstw8 ; *wt = twt8; }
else if( nint == 27 ) {*bcord = rstw27 ; *wt = twt27; }
else if( nint == 64 ) {
/* rstw = (DARR4 *)malloc(64*sizeof(DARR4)); */
twt = (double *)malloc(64*sizeof(double));
i=j=k=0;
for(l=0;l<64;l++){
twt[l]=bw4[i]*bw4[j]*bw4[k];
i++;
if(i == 4){
i=0 ; j++ ;
if(j == 4) { j=0; k++;}
}
}
*bcord = rstw64; *wt = twt;
} else if( nint == 125) {
rstw = (DARR4 *)malloc(125*sizeof(DARR4));
twt = (double *)malloc(125*sizeof(double));
i=j=k=0;
for(l=0;l<125;l++){
rstw[l][0]=bp5[i];
rstw[l][1]=bp5[j];
rstw[l][2]=bp5[k];
rstw[l][3]=0.0;
twt[l]=bw5[i]*bw5[j]*bw5[k];
i++;
if(i == 5){
i=0 ; j++ ;
if(j == 5) { j=0; k++;}
}
}
*bcord = rstw; *wt = twt;
} else {
fprintf(stderr,"\n%d integration points unsupported; give {8,27,64,125,.}\n",nint);
retval = 0;
}
return retval ;
}
#ifdef __cplusplus
}
#endif
| 27.379661 | 87 | 0.588832 |
8464692653baa6fee12037102eceb677590847a0 | 1,121 | h | C | XVim2/XcodeHeader/IDEKit/IDEOpenInProjectViewControllerDataSourceItem.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 2,453 | 2017-09-07T00:07:49.000Z | 2022-03-29T22:32:10.000Z | XVim2/XcodeHeader/IDEKit/IDEOpenInProjectViewControllerDataSourceItem.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 373 | 2017-09-20T04:16:11.000Z | 2022-03-26T17:01:37.000Z | XVim2/XcodeHeader/IDEKit/IDEOpenInProjectViewControllerDataSourceItem.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 260 | 2017-09-16T15:31:41.000Z | 2022-02-07T02:52:29.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 30 2020 21:18:12).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <objc/NSObject.h>
@class NSDate, NSImage, NSString, NSURL;
@interface IDEOpenInProjectViewControllerDataSourceItem : NSObject
{
NSURL *_url;
NSImage *_image;
NSString *_name;
NSString *_truncatedPath;
NSDate *_lastOpenedDate;
NSString *_shortLastOpenedDate;
}
+ (id)itemForURL:(id)arg1;
- (void).cxx_destruct;
@property(readonly) NSString *shortLastOpenedDate; // @synthesize shortLastOpenedDate=_shortLastOpenedDate;
@property(readonly) NSDate *lastOpenedDate; // @synthesize lastOpenedDate=_lastOpenedDate;
@property(readonly) NSString *truncatedPath; // @synthesize truncatedPath=_truncatedPath;
@property(readonly) NSString *name; // @synthesize name=_name;
@property(readonly) NSImage *image; // @synthesize image=_image;
@property(readonly) NSURL *url; // @synthesize url=_url;
- (id)description;
- (id)initWithURL:(id)arg1 image:(id)arg2 name:(id)arg3 truncatedPath:(id)arg4 lastOpenedDate:(id)arg5 shortLastOpenedDate:(id)arg6;
@end
| 32.970588 | 132 | 0.749331 |
57b09bcf6e5204082443878b13b71dd7293b89ba | 427 | h | C | MatterVM/include/mtr/ModuleLoader.h | k0dep/MatterVM | 2c4589714238d5321f0aee52ae1e2c5f5adb38ae | [
"MIT"
] | 3 | 2019-01-29T08:13:40.000Z | 2019-06-21T16:22:12.000Z | MatterVM/include/mtr/ModuleLoader.h | k0dep/MatterVM | 2c4589714238d5321f0aee52ae1e2c5f5adb38ae | [
"MIT"
] | null | null | null | MatterVM/include/mtr/ModuleLoader.h | k0dep/MatterVM | 2c4589714238d5321f0aee52ae1e2c5f5adb38ae | [
"MIT"
] | null | null | null | #pragma once
#ifndef _MODULELOADER_H_
#define _MODULELOADER_H_
#include <string>
#include <memory>
#include <map>
#include <vector>
#include <mtr/VModuleBase.h>
namespace mtr
{
class ModuleLoader
{
public:
static std::string path;
static std::shared_ptr<VModuleBase> load_moodule(std::string name);
protected:
static std::map<std::string, std::shared_ptr<VModuleBase>> _cache;
};
}
#endif // !_MODULELOADER_H_ | 15.814815 | 69 | 0.737705 |
b3ee3349f9a7dfc39d4ec0acb81c517c7e4fcb93 | 1,328 | h | C | PathMap.h | Magtheridon96/Unfinished-RPG | f002a7e19684f31e6158ca78e24bdd514932d72c | [
"MIT"
] | 1 | 2015-09-14T13:19:16.000Z | 2015-09-14T13:19:16.000Z | PathMap.h | Magtheridon96/Unfinished-RPG | f002a7e19684f31e6158ca78e24bdd514932d72c | [
"MIT"
] | null | null | null | PathMap.h | Magtheridon96/Unfinished-RPG | f002a7e19684f31e6158ca78e24bdd514932d72c | [
"MIT"
] | null | null | null | //
// PathMap.h
// Game Engine v0.0.0.0
//
// Created by Magtheridon96 on 7/26/13.
// Copyright (c) 2013 EventHorizon. All rights reserved.
//
#pragma once
#include "SFML/Graphics.hpp"
#include "ResourcePath.h"
#include "ResourceCache.h"
#include "ResourceDirectory.h"
#include <vector>
#include <memory>
#include <sstream>
class path_map {
public:
enum class pathability { unpathable, pathable };
class column {
private:
static unsigned char null;
private:
std::vector<unsigned char> data;
public:
column();
column(unsigned short height);
column(column&& rhs);
column& operator=(column&& rhs);
~column();
unsigned char& operator[](int y);
const unsigned char& operator[](int y) const;
};
private:
static column null;
static unsigned char zero;
protected:
std::vector<column> pathable_;
unsigned short width_;
unsigned short height_;
public:
path_map();
path_map(std::istream& stream);
path_map(path_map&& rhs);
path_map& operator=(path_map&& rhs);
~path_map();
void load(std::istream& stream);
column& operator[](int x);
const column& operator[](int x) const;
unsigned short width() const;
unsigned short height() const;
};
| 21.079365 | 57 | 0.622741 |
7ee0a9a28453e8d647f1ae40347881f8dff578ac | 3,789 | h | C | src/CGnuPlotStyleSunburstPainter.h | colinw7/CQGnuPlot | 8001b0a0d40c1fde8e5efe05ebe0c9b0541daa94 | [
"MIT"
] | null | null | null | src/CGnuPlotStyleSunburstPainter.h | colinw7/CQGnuPlot | 8001b0a0d40c1fde8e5efe05ebe0c9b0541daa94 | [
"MIT"
] | null | null | null | src/CGnuPlotStyleSunburstPainter.h | colinw7/CQGnuPlot | 8001b0a0d40c1fde8e5efe05ebe0c9b0541daa94 | [
"MIT"
] | 1 | 2019-04-01T13:08:45.000Z | 2019-04-01T13:08:45.000Z | #ifndef CGnuPlotStyleSunburstPainter_H
#define CGnuPlotStyleSunburstPainter_H
#include <CSunburst.h>
#include <CGnuPlotRenderer.h>
#include <CGnuPlotPlot.h>
#include <CGnuPlotPieObject.h>
class CGnuPlotStyleSunburstPainter : public CSunburstPainter {
public:
typedef std::pair<CHAlignType,double> HAlignPos;
typedef std::pair<CVAlignType,double> VAlignPos;
public:
CGnuPlotStyleSunburstPainter(CGnuPlotPlot *plot, CGnuPlotRenderer *renderer) :
plot_(plot), renderer_(renderer) {
assert(plot_);
}
const CRGBA &borderColor() const { return borderColor_; }
void setBorderColor(const CRGBA &v) { borderColor_ = v; }
const std::string &palette() const { return palette_; }
void setPalette(const std::string &v) { palette_ = v; }
void drawNode(CSunburst::Node *node) {
double xc = 0.0;
double yc = 0.0;
double r1 = node->r();
double r2 = r1 + node->dr();
double a1 = node->a();
double da = node->da();
double a2 = a1 + da;
CSunburst::HierNode *parent = 0;
if (node->parent() && ! node->parent()->isRoot())
parent = node->parent();
CSunburst::HierNode *root = parent;
while (root && root->parent() && ! root->parent()->isRoot())
root = root->parent();
int rcolorId = (root ? root->colorId() : node->colorId());
double r = 0.0;
if (node->isHier())
r = (parent ? (1.0*parent->childIndex(node))/(parent->getChildren().size() - 1.0) : 0.0);
else
r = (parent ? (1.0*parent->nodeIndex(node))/(parent->getNodes().size() - 1.0) : 0.0);
CPoint2D pc(xc, yc);
CRGBA color = getColor(rcolorId) + r*CRGBA(0.5, 0.5, 0.5);
if (plot_->isCacheActive()) {
CGnuPlotPieObject *pie = plot_->pieObjects()[ind_];
pie->setCenter(pc);
pie->setRadius(r2);
pie->setInnerRadius(r1/r2);
pie->setAngle1(a1);
pie->setAngle2(a2);
if (! pie->testAndSetUsed()) {
CGnuPlotFillP fill (pie->fill ()->dup());
CGnuPlotStrokeP stroke(pie->stroke()->dup());
pie->setName (node->name());
pie->setValue (node->size());
pie->setLabelRadius((r1 + 0.01)/r2);
pie->setRotatedText (true);
pie->setExplodeSelected(false);
fill->setType (CGnuPlotTypes::FillType::SOLID);
fill->setColor(color);
stroke->setWidth(1);
stroke->setColor(borderColor());
pie->setFill (fill );
pie->setStroke(stroke);
}
}
else {
double ta = a1 + da/2.0;
double tangle = CAngle::Deg2Rad(ta);
double lr = r1 + 0.01;
double tc = cos(tangle);
double ts = sin(tangle);
double tx = pc.x + lr*tc;
double ty = pc.y + lr*ts;
CPoint2D tp(tx, ty);
CRGBA tc1 = color.bwContrast();
//---
renderer_->fillPieSlice(pc, r1, r2, a1, a2, color);
renderer_->drawPieSlice(pc, r1, r2, a1, a2, true, borderColor(), 1);
#if 0
renderer_->drawText(tp, node->name(), tc1);
#endif
if (tc >= 0)
renderer_->drawRotatedText(tp, node->name(), ta,
HAlignPos(CHALIGN_TYPE_LEFT , 0),
VAlignPos(CVALIGN_TYPE_CENTER, 0), tc1);
else
renderer_->drawRotatedText(tp, node->name(), 180.0 + ta,
HAlignPos(CHALIGN_TYPE_RIGHT , 0),
VAlignPos(CVALIGN_TYPE_CENTER, 0), tc1);
}
++ind_;
}
private:
CRGBA getColor(int i) {
return CGnuPlotStyleInst->indexColor(palette(), i);
}
private:
CGnuPlotPlot *plot_ { 0 };
CGnuPlotRenderer *renderer_ { 0 };
int ind_ { 0 };
CRGBA borderColor_ { 0, 0, 0 };
std::string palette_ { "subburst" };
};
#endif
| 26.496503 | 95 | 0.571127 |
f1c49a844eb51629a166d802b81b49411e547be2 | 2,698 | h | C | ks/include/ks/list_impl.h | acplt/acplt-ks | 9c1acdeeabd93d1627a0fe4c5ac7888144c950fe | [
"Artistic-1.0-cl8",
"Apache-2.0"
] | null | null | null | ks/include/ks/list_impl.h | acplt/acplt-ks | 9c1acdeeabd93d1627a0fe4c5ac7888144c950fe | [
"Artistic-1.0-cl8",
"Apache-2.0"
] | null | null | null | ks/include/ks/list_impl.h | acplt/acplt-ks | 9c1acdeeabd93d1627a0fe4c5ac7888144c950fe | [
"Artistic-1.0-cl8",
"Apache-2.0"
] | null | null | null | /* -*-plt-c++-*- */
#ifndef KS_LIST_IMPL_INCLUDED
#define KS_LIST_IMPL_INCLUDED
/* $Header: /home/david/cvs/acplt/ks/include/ks/list_impl.h,v 1.9 2008-09-22 08:26:09 henning Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 1999
* Lehrstuhl fuer Prozessleittechnik, RWTH Aachen
* D-52064 Aachen, Germany.
* All rights reserved.
*
* This file is part of the ACPLT/KS Package which is licensed as open
* source under the Artistic License; you can use, redistribute and/or
* modify it under the terms of that license.
*
* You should have received a copy of the Artistic License along with
* this Package; see the file ARTISTIC-LICENSE. If not, write to the
* Copyright Holder.
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES
* OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
//////////////////////////////////////////////////////////////////////
#if !PLT_SEE_ALL_TEMPLATES
#include "ks/list.h"
#include "plt/list_impl.h"
#endif
//////////////////////////////////////////////////////////////////////
template <class T>
bool
KsList<T>::xdrEncode(XDR * xdr) const
{
PLT_PRECONDITION(xdr->x_op == XDR_ENCODE);
// write size
u_long sz = KsList<T>::size();
if (! ks_xdre_u_long(xdr, &sz) ) return false;
// write elements
for (PltListIterator<T> it(*this); it; ++it) {
if (! it->xdrEncode(xdr) ) {
// serialization of element failed
return false;
}
}
return true;
}
//////////////////////////////////////////////////////////////////////
template <class T>
bool
KsList<T>::xdrDecode(XDR * xdr)
{
PLT_PRECONDITION(xdr->x_op == XDR_DECODE);
u_long count;
if ( ! ks_xdrd_u_long(xdr, &count) ) return false;
// flush old elements
while (! KsList<T>::isEmpty() ) {
KsList<T>::removeFirst();
}
for ( u_long i=0; i < count; ++i) {
bool ok=false;
T elem(xdr, ok);
if (! ok) return false;
if (! this->addLast(elem) ) return false;
}
return true;
}
//////////////////////////////////////////////////////////////////////
template <class T>
KsList<T> *
KsList<T>::xdrNew(XDR * xdr)
{
bool ok=false;
KsList<T> * p = new KsList<T>(xdr, ok);
if ( !ok && p) {
delete p;
p = 0;
}
return p;
}
//////////////////////////////////////////////////////////////////////
#endif // KS_LIST_IMPL_INCLUDED
// EOF ks/list_impl.h
| 28.702128 | 102 | 0.504448 |
041df606ec929b14b10ffdf36822fdfa592d3c82 | 466 | h | C | src/PluginLib/VisualizationConsts.h | gomezalberto/pretus | 63b05419f70ecf8b28ccbb6191eab79637c051ac | [
"MIT"
] | 18 | 2021-11-05T13:04:00.000Z | 2022-01-31T14:14:08.000Z | src/PluginLib/VisualizationConsts.h | gomezalberto/pretus | 63b05419f70ecf8b28ccbb6191eab79637c051ac | [
"MIT"
] | 27 | 2021-09-14T14:04:28.000Z | 2022-02-15T09:58:30.000Z | src/PluginLib/VisualizationConsts.h | gomezalberto/pretus | 63b05419f70ecf8b28ccbb6191eab79637c051ac | [
"MIT"
] | 1 | 2021-12-16T12:51:32.000Z | 2021-12-16T12:51:32.000Z | #pragma once
#include <map>
#include <vector>
#include <string>
class VisualizationConsts
{
public:
static const std::map<int, std::string> &DataTypeStrings();
static const std::vector<int> &StandardLayerOrder();
static const int TargetWindowWidth() { return 1920; }
static const int TargetWindowHeight() { return 1080; }
static const int InformationPanelWidth() { return 280; }
static const int NormalTextPixelSize() { return 15; }
};
| 22.190476 | 63 | 0.706009 |
cca497865c9190a2c1ad3fd67d4bae1758333c45 | 909 | h | C | Sequence.h | rablack/LightBox | b184cbf871b19e06bb2fa078ed788390d98baad6 | [
"MIT"
] | null | null | null | Sequence.h | rablack/LightBox | b184cbf871b19e06bb2fa078ed788390d98baad6 | [
"MIT"
] | null | null | null | Sequence.h | rablack/LightBox | b184cbf871b19e06bb2fa078ed788390d98baad6 | [
"MIT"
] | null | null | null | #ifndef SEQUENCE_H
#define SEQUENCE_H
#include <Arduino.h>
#include "Effect.h"
class Sequence {
public:
enum State : uint8_t {
INIT,
STOP,
PLAY,
PAUSE
};
Sequence(void) : effectList(0), currentEffect(0), state(INIT) {
}
virtual ~Sequence(void) {
releaseEffects();
}
virtual void initEffects(void) = 0;
void addEffect(Effect* effect);
void releaseEffects(void);
void update(Adafruit_NeoPixel& strip);
void forward(unsigned long ms);
void rewind(unsigned long ms);
void stop(void);
void play(void);
void finished(void) { stop(); }
protected:
void updatePlay(Adafruit_NeoPixel& strip);
void updatePause(Adafruit_NeoPixel& strip);
private:
struct EffectNode {
Effect* effect;
EffectNode* next;
unsigned int startTime;
};
EffectNode* effectList;
EffectNode* currentEffect;
unsigned long timeCounter;
State state;
};
#endif
| 17.823529 | 65 | 0.685369 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.