# include <float.h>
# include <math.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <time.h>
int main ( int argc, char *argv[] );
char ch_cap ( char ch );
int ch_eqi ( char ch1, char ch2 );
int ch_to_digit ( char ch );
double *fem1d_approximate ( int sample_node_num, int sample_value_dim,
double sample_node_x[], double sample_value[], int fem_node_num,
double fem_node_x[], int fem_element_order, int fem_element_num,
int fem_value_dim, int fem_value_num );
int file_column_count ( char *input_filename );
int file_row_count ( char *input_filename );
int *i4mat_data_read ( char *input_filename, int m, int n );
void i4mat_header_read ( char *input_filename, int *m, int *n );
double piecewise_linear_product_quad ( double a, double b, int f_num,
double f_x[], double f_v[], int g_num, double g_x[], double g_v[] );
double r8_min ( double x, double y );
int r83_np_fa ( int n, double a[] );
double *r83_np_sl ( int n, double a_lu[], double b[], int job );
double *r8mat_data_read ( char *input_filename, int m, int n );
void r8mat_header_read ( char *input_filename, int *m, int *n );
void r8mat_write ( char *output_filename, int m, int n, double table[] );
double *r8mat_zero_new ( int m, int n );
void r8vec_bracket3 ( int n, double t[], double tval, int *left );
int s_len_trim ( char *s );
int s_to_i4 ( char *s, int *last, int *error );
int s_to_i4vec ( char *s, int n, int ivec[] );
double s_to_r8 ( char *s, int *lchar, int *error );
int s_to_r8vec ( char *s, int n, double rvec[] );
int s_word_count ( char *s );
void timestamp ( );
/******************************************************************************/
int main ( int argc, char *argv[] )
/******************************************************************************/
/*
Purpose:
MAIN is the main program for FEM1D_PROJECT.
Discussion:
FEM1D_PROJECT reads files defining a sampling of a (scalar or vector)
function of 1 argument, and a list of nodes and elements to use for
a finite element representation of the data.
It computes a set of finite element coefficients to be associated with
the given finite element mesh, and writes that information to a file
so that an FEM representation is formed by the node, element and value
files.
Usage:
fem1d_project sample_prefix fem_prefix
where 'sample_prefix' is the common prefix for the SAMPLE files:
* sample_prefix_nodes.txt, the node coordinates where samples were taken,
* sample_prefix_values.txt, the sample values.
and 'fem_prefix' is the common prefix for the FEM files:
* fem_prefix_nodes.txt, the node coordinates.
* fem_prefix_elements.txt, the nodes that make up each element;
* fem_prefix_values.txt, the values defined at each node.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
25 July 2019
Author:
John Burkardt
*/
{
char fem_element_filename[255];
int *fem_element_node;
int fem_element_num;
int fem_element_order;
int fem_node_dim;
char fem_node_filename[255];
int fem_node_num;
double *fem_node_x;
char fem_prefix[255];
double *fem_value;
int fem_value_dim;
char fem_value_filename[255];
int fem_value_num;
char sample_prefix[255];
int sample_node_dim;
char sample_node_filename[255];
int sample_node_num;
double *sample_node_x;
int sample_value_dim;
int sample_value_num;
double *sample_value;
char sample_value_filename[255];
timestamp ( );
printf ( "\n" );
printf ( "FEM1D_PROJECT\n" );
printf ( " C version.\n" );
printf ( "\n" );
printf ( " Read files defining a sampling of a function of 1 argument.\n" );
printf ( " Read files defining a finite element mesh.\n" );
printf ( " Project the sample data onto the mesh, and\n" );
printf ( " write a file of FEM coefficient values.\n" );
/*
Get the number of command line arguments.
*/
if ( 1 < argc )
{
strcpy ( sample_prefix, argv[1] );
}
else
{
printf ( "\n" );
printf ( "Enter the sample file prefix:\n" );
scanf ( "%s", sample_prefix );
}
if ( 2 < argc )
{
strcpy ( fem_prefix, argv[2] );
}
else
{
printf ( "\n" );
printf ( "Enter the FEM file prefix:\n" );
scanf ( "%s", fem_prefix );
}
/*
Create the filenames.
*/
strcpy ( sample_node_filename, sample_prefix );
strcat ( sample_node_filename, "_nodes.txt" );
strcpy ( sample_value_filename, sample_prefix );
strcat ( sample_value_filename, "_values.txt" );
strcpy ( fem_node_filename, fem_prefix );
strcat ( fem_node_filename, "_nodes.txt" );
strcpy ( fem_element_filename, fem_prefix );
strcat ( fem_element_filename, "_elements.txt" );
strcpy ( fem_value_filename, fem_prefix );
strcat ( fem_value_filename, "_values.txt" );
/*
Read the SAMPLE data.
*/
r8mat_header_read ( sample_node_filename, &sample_node_dim,
&sample_node_num );
sample_node_x = r8mat_data_read ( sample_node_filename, sample_node_dim,
sample_node_num );
printf ( "\n" );
printf ( " Sample node spatial dimension is %d\n", sample_node_dim );
printf ( " Sample node number is %d\n", sample_node_num );
if ( sample_node_dim != 1 )
{
printf ( "\n" );
printf ( "FEM1D_PROJECT - Fatal error!\n" );
printf ( " Spatial dimension of the sample nodes is not 1.\n" );
exit ( 1 );
}
r8mat_header_read ( sample_value_filename, &sample_value_dim,
&sample_value_num );
printf ( " The SAMPLE value dimension is %d\n", sample_value_dim );
printf ( " the SAMPLE value number is %d\n", sample_value_num );
if ( sample_value_num != sample_node_num )
{
printf ( "\n" );
printf ( "FEM1D_PROJECT - Fatal error!\n" );
printf ( " Number of sample values and nodes differ.\n" );
exit ( 1 );
}
sample_value = r8mat_data_read ( sample_value_filename, sample_value_dim,
sample_value_num );
/*
Read the FEM data.
*/
r8mat_header_read ( fem_node_filename, &fem_node_dim, &fem_node_num );
printf ( "\n" );
printf ( " The FEM node dimension is %d\n", fem_node_dim );
printf ( " The FEM node number is %d\n", fem_node_num );
if ( fem_node_dim != 1 )
{
printf ( "\n" );
printf ( "FEM1D_PROJECT - Fatal error!\n" );
printf ( " Spatial dimension of the nodes is not 1.\n" );
exit ( 1 );
}
fem_node_x = r8mat_data_read ( fem_node_filename, fem_node_dim, fem_node_num );
i4mat_header_read ( fem_element_filename, &fem_element_order, &fem_element_num );
printf ( " The FEM element order is %d\n", fem_element_order );
printf ( " The FEM element number is %d\n", fem_element_num );
fem_element_node = i4mat_data_read ( fem_element_filename, fem_element_order,
fem_element_num );
/*
Compute the FEM values.
*/
fem_value_dim = sample_value_dim;
fem_value_num = fem_node_num;
fem_value = fem1d_approximate ( sample_node_num, sample_value_dim, sample_node_x,
sample_value, fem_node_num, fem_node_x, fem_element_order,
fem_element_num, fem_value_dim, fem_value_num );
/*
Write the FEM values.
*/
r8mat_write ( fem_value_filename, fem_value_dim, fem_value_num,
fem_value );
printf ( "\n" );
printf ( " Projected FEM values written to \"%s\"\n", fem_value_filename );
/*
Free memory.
*/
free ( fem_element_node );
free ( fem_node_x );
free ( fem_value );
free ( sample_node_x );
free ( sample_value );
/*
Terminate.
*/
printf ( "\n" );
printf ( "FEM1D_PROJECT\n" );
printf ( " Normal end of execution.\n" );
printf ( "\n" );
timestamp ( );
return 0;
}
/******************************************************************************/
char ch_cap ( char ch )
/******************************************************************************/
/*
Purpose:
CH_CAP capitalizes a single character.
Discussion:
This routine should be equivalent to the library "toupper" function.
Licensing:
This code is distri
C 代码 将数据投影到有限元空间,包括最小二乘 数据的近似值.rar
版权申诉
130 浏览量
2022-11-13
21:16:25
上传
评论
收藏 11KB RAR 举报
卷积神经网络
- 粉丝: 337
- 资源: 8460
最新资源
- 服务器概述服务器概述服务器概述服务器概述.txt
- 华中农业大学python实验题.txt
- 海康威视相机采图交叉编译示例程序,c++
- DETR-基于Tensorflow实现DETR目标检测算法-附流程教程+项目源码-优质项目实战.zip
- 3d激光slam地图发布程序,3d地图点云处理,c++程序
- 送给妈妈的一束鲜花.zip(母亲节祝福HTML源码)
- 稀疏化DETR-基于Pytorch实现稀疏化DETR-SparseDETR-附流程教程+项目源码-优质项目实战.zip
- 人工分类:SLTM的微博评论二分类数据集
- (自适应手机端)响应式房产合同知识产权网站pbootcms模板 企业管理类网站源码下载.zip
- (自适应手机端)响应式动力刀座pbootcms网站模板 五金机械设备类网站源码下载.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈