错误:流畅.14.5.7 UDF(分割违规)

时间:2014-05-21 13:24:59

标签: c fluent

我正在使用Fluent 14.5.7,并且在使用UDF时出现了一些编程错误。 我试图解决的模拟是在水平固定床反应器中的脱硫过程。在将UDF与反应(CaO和SO2之间)包括在内之前,它完美地起作用。 我已经尝试更改一些参数,返回一个常量值(用* rr = 60替换* rr = 60 * k * Beta * NSO2),以及其他一些事情,但出现了相同的错误。

这是我的C代码:

/*********************************************************************/
#include "udf.h"
#include "sg_mphase.h"
DEFINE_HET_RXN_RATE(SO2_capture , c, t, hr, mw,yi, rr, rr_t)
{
Thread **pt = THREAD_SUB_THREADS(t);
Thread *tg = pt[0];
Thread *ts = pt[1];
real XCaO = C_YI(c,ts,0); /* Para checkear que hay sorbente*/
real XSO2 = C_YI(c,tg,0); /* Fraccion masica SO2 en la fase gas*/
real mwSO2 = 64.0638;
real DENS_Gas = C_R(c,tg); /* Si hay problemas se puede considerar que es constante*/
real VReac=6333.843; /* Volumen total del reactor en cm³ */
real NSO2 = XSO2 / mwSO2 * DENS_Gas * VReac; /* Controla el valor de NSO2 */
real Time_min = CURRENT_TIME / 60;

/*valores de constantes a 400ºC */

real EDiff = -49300; /*mejor sacar el negativo de la potencia*/
real aa1 = 2.10e-03;
real aa2 = 12.9e-02;
real aa3 = -0.66;  /*mejor sacar el negativo de la potencia*/
real kdiff = aa1 * exp (EDiff/(8.314 * C_T(c,t))) * (1 + aa2 * exp (aa3*Time_min));
real aa4 = 0.82;
real aa5 = -1;  /*mejor sacar el negativo de la potencia*/
real Beta = (1 - aa4 * exp (aa5*Time_min));
real k0 = 1.78e-02;
real Ea = -13900;  /*mejor sacar el negativo de la potencia*/
real ks = k0 * exp (Ea/(8.314 * C_T(c,t)));
real k = (ks * kdiff)/(ks + kdiff);
if (XCaO != 0)
{
     *rr = 60 * k * Beta * NSO2;    
}
else 
{
     *rr = 0;   
}
/*return;*/
}

/****************************************************************/

当我运行模拟时,它会显示以下错误:

===============================================================================
Stack backtrace generated for process id 27426 on signal 1 :
1000000: /usr/local/ansys_inc/v154/fluent/fluent14.5.7/lnamd64/2ddp/fluent.14.5.7 [0x166a164]
1000000: /usr/local/ansys_inc/v154/fluent/fluent14.5.7/lnamd64/2ddp/fluent.14.5.7 [0x166a8d3]
1000000: /lib64/libpthread.so.0 [0x3736e0eca0]
1000000: Kin_Sulp_3/lnamd64/2ddp/libudf.so(SO2_capture+0x9b) [0x2afee78f644f]
Check the file fluenterror.log for details.
Please include this information with any bug report you file on this issue!
===============================================================================

Error: fluent.14.5.7 received a fatal signal (SEGMENTATION VIOLATION).
Error Object: #f

fluenterror.log文件提供以下信息:

Received signal 1 [time 5/21/14 13:23:5]
1000000: /usr/local/ansys_inc/v145/fluent/fluent14.5.7/lnamd64/2ddp/fluent.14.5.7 [0x166a287]
1000000: /usr/local/ansys_inc/v145/fluent/fluent14.5.7/lnamd64/2ddp/fluent.14.5.7 [0x166a8d3]
1000000: /lib64/libpthread.so.0 [0x3736e0eca0]
1000000: Kin_Sulp_3/lnamd64/2ddp/libudf.so(SO2_capture+0x9b) [0x2afee78f644f]

Error [client] [time 5/21/14 13:23:6] fluent.14.5.7 received a fatal signal (SEGMENTATION VIOLATION).
999999:/usr/local/ansys_inc/v145/fluent/fluent14.5.7/lnamd64/2ddp/fluent.14.5.7(CX_Primitive_Error+0x204) [0x166a704]
999999: /usr/local/ansys_inc/v145/fluent/fluent14.5.7/lnamd64/2ddp/fluent.14.5.7 [0x166a91f]
999999: /lib64/libpthread.so.0 [0x3736e0eca0]
999999: Kin_Sulp_3/lnamd64/2ddp/libudf.so(SO2_capture+0x9b) [0x2afee78f644f]

任何建议都将受到赞赏,如果您需要更多信息,我将很乐意给予。

谢谢!

1 个答案:

答案 0 :(得分:0)

我也在流利地工作,想为动态网格制作UDF,所以需要一个用于C ++的udf.h头文件。 我从谷歌得到了一个。但它显示了很多错误:

 /* $OpenBSD: udf.h,v 1.20 2014/11/18 10:42:15 dlg Exp $    */

    /*
     * Copyright (c) 2001, 2002 Scott Long <scottl@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.
     *
     * $FreeBSD: src/sys/fs/udf/udf.h,v 1.9 2004/10/29 10:40:58 phk Exp $
     */

    /*
     * Ported to OpenBSD by Pedro Martelletto in February 2005.
     */

    #define UDF_HASHTBLSIZE 100
    #include <iostream>
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <cstdlib>
    #include <ctime>
    #include <cmath>
    #include <fstream>

    #define u_diroff    un_u.u_diroff
    #define u_vatlen    un_u.u_vatlen

    typedef unsigned __int32 uint32_t;
    typedef uint32_t udfino_t;

    struct unode {
        struct LIST_ENTRY *u_le;
        struct vnode *u_vnode;
        struct vnode *u_devvp;
        struct umount *u_ump;
        struct lock u_lock;
        dev_t u_dev;
        udfino_t u_ino;
        union {
            long u_diroff;
            long u_vatlen;
        } un_u;
        struct extfile_entry *u_fentry;
    };

    struct umount {
        int um_flags;
        struct mount *um_mountp;
        struct vnode *um_devvp;
        dev_t um_dev;
        int um_bsize;
        int um_bshift;
        int um_bmask;
        uint32_t um_start;
        uint32_t um_realstart;
        uint32_t um_len;
        uint32_t um_reallen;
        uint32_t um_meta_start;
        uint32_t um_meta_len;
        struct unode *um_vat;
        struct long_ad um_root_icb;
        LIST_HEAD(udf_hash_lh, unode) *um_hashtbl;
        SIPHASH_KEY um_hashkey;
        u_long um_hashsz;
        struct mutex um_hashmtx;
        int um_psecs;
        int um_stbl_len;
        struct udf_sparing_table *um_stbl;
    };

    #define UDF_MNT_FIND_VAT    0x01    /* Indicates a VAT must be found */
    #define UDF_MNT_USES_VAT    0x02    /* Indicates a VAT must be used */
    #define UDF_MNT_USES_META   0x04    /* Indicates we are using a Metadata partition*/

    #define VTOU(vp)    ((struct unode *)((vp)->v_data))

    #ifdef _KERNEL

    struct udf_dirstream {
        struct unode    *node;
        struct umount   *ump;
        struct buf  *bp;
        uint8_t     *data;
        uint8_t     *buf;
        int     fsize;
        int     off;
        int     this_off;
        int     offset;
        int     size;
        int     error;
        int     fid_fragment;
    };

    #define VFSTOUDFFS(mp)  ((struct umount *)((mp)->mnt_data))

    /*
     * The block layer refers to things in terms of 512 byte blocks by default.
     * btodb() is expensive, so speed things up.
     * Can the block layer be forced to use a different block size?
     */
    #define RDSECTOR(devvp, sector, size, bp) \
        bread(devvp, \
            ((daddr_t)(sector) << ump->um_bshift) / DEV_BSIZE, size, bp)

    static __inline int
    udf_readlblks(struct umount *ump, int sector, int size, struct buf **bp)
    {
        return (RDSECTOR(ump->um_devvp, sector,
                 (size + ump->um_bmask) & ~ump->um_bmask, bp));
    }

    /*
     * Produce a suitable file number from an ICB.  The passed in ICB is expected
     * to be in little endian (meaning that it hasn't been swapped for big
     * endian machines yet).
     * If the fileno resolves to 0, we might be in big trouble.
     * Assumes the ICB is a long_ad.  This struct is compatible with short_ad,
     *     but not ext_ad.
     */
    static __inline udfino_t
    udf_getid(struct long_ad *icb)
    {
        return (letoh32(icb->loc.lb_num));
    }

    int udf_allocv(struct mount *, struct vnode **, struct proc *);
    int udf_hashlookup(struct umount *, udfino_t, int, struct vnode **);
    int udf_hashins(struct unode *);
    int udf_hashrem(struct unode *);
    int udf_checktag(struct desc_tag *, uint16_t);

    typedef uint16_t unicode_t;

    #endif /* _KERNEL */

the following are error:
Error   1   error C2079: 'unode::u_lock' uses undefined struct 'lock'   h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 57  1   VELOCITY
Error   2   error C2143: syntax error : missing ';' before '.'  h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 61  1   VELOCITY
Error   3   error C2238: unexpected token(s) preceding ';'  h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 61  1   VELOCITY
Error   4   error C2143: syntax error : missing ';' before '.'  h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 62  1   VELOCITY
Error   5   error C2086: 'long unode::<unnamed-tag>::un_u' : redefinition   h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 62  1   VELOCITY
Error   6   error C2238: unexpected token(s) preceding ';'  h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 62  1   VELOCITY
Error   7   error C2079: 'umount::um_root_icb' uses undefined struct 'long_ad'  h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 82  1   VELOCITY
Error   8   error C2061: syntax error : identifier 'udf_hash_lh'    h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 83  1   VELOCITY
Error   9   error C2143: syntax error : missing ';' before '*'  h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 83  1   VELOCITY
Error   10  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 83  1   VELOCITY
Warning 11  warning C4183: 'LIST_HEAD': missing return type; assumed to be a member function returning 'int'    h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 83  1   VELOCITY
Error   12  error C2146: syntax error : missing ';' before identifier 'um_hashkey'  h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 84  1   VELOCITY
Error   13  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 84  1   VELOCITY
Error   14  error C2079: 'umount::um_hashmtx' uses undefined struct 'mutex' h:\5990\cfd validation\rcm\sample udf file\velocity\velocity\velocity\udf.h 86  1   VELOCITY