Example #1
0
/*
 * ***************************************************************************
 * Routine:  Gem_dtor
 *
 * Purpose:  Geometry manager destructor.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC void Gem_dtor(Gem **thee)
{
    int i;

    VASSERT( (*thee) != VNULL );
    if ((*thee) != VNULL) {

        if ((*thee)->iMadePDE) {
            PDE_dtor_default( &((*thee)->pde) );
        }

        Vset_dtor( &((*thee)->vertices) );
        Vset_dtor( &((*thee)->edges) );
        Vset_dtor( &((*thee)->simplices) );
        for (i=0; i<VMAXSQ; i++) {
            Vset_dtor( &((*thee)->sQueM[i]) );
        }

        VDEBUGIO("Gem_dtor: DESTROYING object..");
        if ((*thee)->iMadeVmem) Vmem_dtor( &((*thee)->vmem) );
        Vmem_free( VNULL, 1, sizeof(Gem), (void**)thee );
        VDEBUGIO("..done.\n");

        (*thee) = VNULL;
    }
}
Example #2
0
/*
 * ***************************************************************************
 * Routine:  MCsh_ctor
 *
 * Purpose:  The MCsh constructor.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC MCsh* MCsh_ctor(PDE *tpde, int argc, char **argv)
{
    MCsh *thee = VNULL;

    VDEBUGIO("MCsh_ctor: CREATING object..");

    thee = Vmem_malloc( VNULL, 1, sizeof(MCsh) );
    thee->vmem = Vmem_ctor( "MCsh" );

    VDEBUGIO("..done.\n");

    /* the environment and shell object */
    thee->PR[0] = '\0';
    thee->USER_shell = VNULL;
    thee->vsh = Vsh_ctor(VNULL, argc, argv);

    /* the differential equation object */
    thee->pde = tpde;

    /* the geometry manager object */
    thee->gm = Gem_ctor( VNULL, thee->pde );

    /* the approximation object */
    thee->aprx = Aprx_ctor( VNULL, thee->gm, thee->pde );

    /* the algebra manager object */
    thee->am = AM_ctor( VNULL, thee->aprx );

    return thee;
}
Example #3
0
/*
 * ***************************************************************************
 * Routine:  Bnode_ctor
 *
 * Purpose:  The Block node constructor.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC Bnode* Bnode_ctor(Vmem *vmem, int pnumB, int pnumR[MAXV])
{
    int i;
    Bnode *thee = VNULL;

    VDEBUGIO("Bnode_ctor: CREATING object..");

    thee = Vmem_malloc( VNULL, 1, sizeof(Bnode) );
    if (vmem == VNULL) {
        thee->vmem = Vmem_ctor( "Bnode" );
        thee->iMadeVmem = 1;
    } else {
        thee->vmem = vmem;
        thee->iMadeVmem = 0;
    }

    VDEBUGIO("..done.\n");

    thee->numB   = pnumB;
    for (i=0; i<thee->numB; i++) {
        thee->ND[i] = Node_ctor(vmem, pnumR[i]);
    }

    return thee;
}
Example #4
0
/*
 * ***************************************************************************
 * Routine:  Bmat_dtor
 *
 * Purpose:  The block sparse matrix destructor.
 *
 * Notes:    This destructor does the reverse of Bmat_ctor, and if 
 *           necessary first reverses Bmat_initStructure
 *           (or Bmat_copyStructure).  I.e., if necessary,
 *           it first frees the large integer and real arrays created by
 *           Bmat_initStructure or Bmat_copyStructure, and then frees the
 *           Bmat object itself at the last moment.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC void Bmat_dtor(Bmat **thee)
{
    int p, q;

    /* VASSERT( (*thee) != VNULL ); */
    if ((*thee) != VNULL) {

        /* first free any coarse guy */
        if ( (*thee)->coarse != VNULL ) {
            Bmat_dtor( &((*thee)->coarse) );
        }

        /* next free the large integer and real nonzero structure */
        Bmat_killStructure(*thee);

        /* kill the submatrices themselves */
        Mat_dtor( &((*thee)->AG) );
        for (p=0; p<(*thee)->numB; p++) {
            for (q=0; q<(*thee)->numB; q++) {
                if ( !(*thee)->mirror[p][q] ) {
                    Mat_dtor( &((*thee)->AD[p][q]) );
                }
            }
        }

        /* now kill the object itself */
        VDEBUGIO("Bmat_dtor: DESTROYING object..");
        if ((*thee)->iMadeVmem) Vmem_dtor( &((*thee)->vmem) );
        Vmem_free( VNULL, 1, sizeof(Bmat), (void**)thee );
        VDEBUGIO("..done.\n");

        (*thee) = VNULL;
    }
}
Example #5
0
/*
 * ***************************************************************************
 * Routine:  Vmpi_dtor
 *
 * Purpose:  The Vmpi destructor.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC void Vmpi_dtor(Vmpi **thee)
{
    VDEBUGIO("Vmpi_dtor: DESTROYING object..");
    Vmem_free( VNULL, 1, sizeof(Vmpi), (void**)thee );
#if defined(HAVE_MPI_H)
#if 0
    VASSERT( MPI_SUCCESS == MPI_Finalize() );
#endif
#endif
    VDEBUGIO("..done.\n");
}
Example #6
0
/*
 * ***************************************************************************
 * Routine:  Bmat_ctor
 *
 * Purpose:  The block sparse matrix constructor.
 *
 * Notes:    This constructor only does minimal initialization of a Bmat
 *           object after creating the object itself; it doesn't create
 *           any storage for either the integer structure arrays or the
 *           nonzero storage arrays.
 *
 *           This constructor only fixes the number of blocks and the
 *           numbers of rows and columns in each block; the nonzero
 *           structure is not set yet.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC Bmat* Bmat_ctor(Vmem *vmem, const char *name,
    int pnumB, int pnumR[MAXV], int pnumC[MAXV],
    MATmirror pmirror[MAXV][MAXV])
{
    int p,q;
    char bname[15];
    Bmat *thee = VNULL;

    VDEBUGIO("Bmat_ctor: CREATING object..");

    thee = Vmem_malloc( VNULL, 1, sizeof(Bmat) );
    if (vmem == VNULL) {
        thee->vmem = Vmem_ctor( "Bmat" );
        thee->iMadeVmem = 1;
    } else {
        thee->vmem = vmem;
        thee->iMadeVmem = 0;
    }

    strncpy(thee->name, name, 10);
    thee->coarse = VNULL;
    thee->fine   = VNULL;
    thee->numB   = pnumB;
    for (p=0; p<thee->numB; p++) {
        for (q=0; q<thee->numB; q++) {
            thee->mirror[p][q] = pmirror[p][q];
            thee->AD[p][q]     = VNULL;
        }
    }

    /* create upper-triangular blocks before the lower-triangular blocks */
    for (p=0; p<thee->numB; p++) {
        for (q=0; q<thee->numB; q++) {
            if ( !thee->mirror[p][q] ) {
                sprintf(bname, "%s_%d%d", thee->name, p, q);
                thee->AD[p][q] = Mat_ctor(thee->vmem,bname,pnumR[p],pnumC[q]);
            } else { /* ( thee->mirror[p][q] ) */
                /* first make sure that the mirror of this guy exists! */
                VASSERT( !thee->mirror[q][p] );
                VASSERT( thee->AD[q][p] != VNULL );
                thee->AD[p][q] = thee->AD[q][p];
            }
        }
    }

    VDEBUGIO("..done.\n");

    return thee;
}
Example #7
0
/*
 * ***************************************************************************
 * Routine:  MCsh_dtor
 *
 * Purpose:  The MCsh destructor.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC void MCsh_dtor(MCsh **thee)
{
    VASSERT( (*thee) != VNULL );
    if ((*thee) != VNULL) {

        AM_dtor(   &((*thee)->am) );
        Aprx_dtor( &((*thee)->aprx) );
        Gem_dtor(  &((*thee)->gm) );
        Vsh_dtor(  &((*thee)->vsh) );

        VDEBUGIO("MCsh_dtor: DESTROYING object..");
        Vmem_dtor( &((*thee)->vmem) );
        Vmem_free( VNULL, 1, sizeof(MCsh), (void**)thee );
        VDEBUGIO("..done.\n");

        (*thee) = VNULL;
    }
}
Example #8
0
/*
 * ***************************************************************************
 * Routine:  Bnode_dtor
 *
 * Purpose:  The Block node destructor.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC void Bnode_dtor(Bnode **thee)
{
    int i;

    /* VASSERT( (*thee) != VNULL ); */
    if ((*thee) != VNULL) {

        for (i=0; i<(*thee)->numB; i++) {
            Node_dtor( (&(*thee)->ND[i]) );
        }

        VDEBUGIO("Bnode_dtor: DESTROYING object..");
        if ((*thee)->iMadeVmem) Vmem_dtor( &((*thee)->vmem) );
        Vmem_free( VNULL, 1, sizeof(Bnode), (void**)thee );
        VDEBUGIO("..done.\n"); 

        (*thee) = VNULL;
    }
}
Example #9
0
/*
 * ***************************************************************************
 * Routine:  Vmpi_ctor
 *
 * Purpose:  The Vmpi constructor.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC Vmpi* Vmpi_ctor(void)
{
#if defined(HAVE_MPI_H)
    int dummy;
#endif
    Vmpi *thee = VNULL;
    VDEBUGIO("Vmpi_ctor: CREATING object..");
    thee = Vmem_malloc( VNULL, 1, sizeof(Vmpi) );
    thee->mpi_rank = 0;
    thee->mpi_size = 0;
#if defined(HAVE_MPI_H)
    VASSERT( MPI_SUCCESS == MPI_Initialized(&dummy) );
    VASSERT( MPI_SUCCESS == MPI_Comm_rank(MPI_COMM_WORLD, &(thee->mpi_rank)) );
    VASSERT( MPI_SUCCESS == MPI_Comm_size(MPI_COMM_WORLD, &(thee->mpi_size)) );
    Vnm_setIoTag(thee->mpi_rank, thee->mpi_size);
    Vnm_print(2,"Vmpi_ctor: process %d of %d is ALIVE!\n",
        thee->mpi_rank, thee->mpi_size);
#endif
    VDEBUGIO("..done.\n");
    return thee;
}
Example #10
0
/*
 * ***************************************************************************
 * Routine:  Slu_dtor
 *
 * Purpose:  The Slu destructor.
 *
 * Author:   Michael Holst and Stephen Bond
 * ***************************************************************************
 */
VPUBLIC void Slu_dtor(Slu **thee)
{
    VASSERT( (*thee) != VNULL );
    if ((*thee) != VNULL) {

        /* destroy the factorization */
        if( (*thee)->statLU == 1 ) {
            umfpack_di_free_numeric( &((*thee)->work) );
            (*thee)->statLU = 0;
        }

        /* finally destroy this container */
        VDEBUGIO("Slu_dtor: DESTROYING object..");
        if ((*thee)->iMadeVmem) Vmem_dtor( &((*thee)->vmem) );
        Vmem_free( VNULL, 1, sizeof(Slu), (void**)thee );
        VDEBUGIO("..done.\n");

        (*thee) = VNULL;

    }
}
Example #11
0
/*
 * ***************************************************************************
 * Routine:  Gem_ctor
 *
 * Purpose:  Geometry manager constructor.
 *
 * Author:   Michael Holst
 * ***************************************************************************
 */
VPUBLIC Gem* Gem_ctor(Vmem *vmem, PDE *tpde)
{
    int i;
    Gem* thee = VNULL;

    thee = Vmem_malloc( VNULL, 1, sizeof(Gem) );
    if (vmem == VNULL) {
        thee->vmem = Vmem_ctor( "Gem" );
        thee->iMadeVmem = 1;
    } else {
        thee->vmem = vmem;
        thee->iMadeVmem = 0;
    }
   
    VDEBUGIO("Gem_ctor: CREATING object..");
    VDEBUGIO("..done.\n");

    thee->xUp     = defaultxUpFunc;
    thee->xUpFlag = 0;

    if (tpde != VNULL) {
        thee->iMadePDE = 0;
        thee->pde      = tpde;
    } else {
        thee->iMadePDE = 1;
        thee->pde      = PDE_ctor_default();
    }

    thee->vertices  = VNULL;
    thee->edges     = VNULL;
    thee->simplices = VNULL;
    for (i=0; i<VMAXSQ; i++) {
        thee->sQueM[i] = VNULL;
    }

    Gem_reset(thee, 0, 0);

    return thee;
}
Example #12
0
/*
 * ***************************************************************************
 * Routine:  Slu_ctor
 *
 * Purpose:  The Slu constructor.
 *
 * Author:   Michael Holst and Stephen Bond
 * ***************************************************************************
 */
VPUBLIC Slu* Slu_ctor(Vmem *vmem, int skey, int m, int n, int nnz,
    int *ia, int *ja, double *a)
{
    Slu* thee = VNULL;

    VDEBUGIO("Slu_ctor: CREATING object..");

    thee = Vmem_malloc( VNULL, 1, sizeof(Slu) );
    if (vmem == VNULL) {
        thee->vmem = Vmem_ctor( "Slu" );
        thee->iMadeVmem = 1;
    } else {
        thee->vmem = vmem;
        thee->iMadeVmem = 0;
    }

    /* dimensions */
    thee->m = m;
    thee->n = n;

    /* storage key */
    thee->skey = skey;

    /* pointer to factors */
    thee->work = VNULL;

    /* arrays */
    thee->a  = a;
    thee->ia = ia;
    thee->ja = ja;

    VDEBUGIO("..done.\n");

    /* return */
    return thee;
}