/*
 $Id: elements3mc.cc,v 1.2 1996/10/11 15:15:23 bzferdma Exp $
 (C)opyright 1996 by Konrad-Zuse-Center, Berlin
 All rights reserved.
 Part of the Kaskade distribution
*/

#include "elements3mc.h"

#include "numerics.h"
#include "triang.h"
#include "materials.h"
#include "integ.h"


//-------------------------------------------------------------------------

	
MCTetra:: MCTetra(Material* material0, int nComp0)  
			 
	    : Tetra(), nComp(nComp0), 
	      noOfNodes(nComp0*NoOfBaseNodes()), Node(NoOfBaseNodes(),nComp0)

{ 
    // --    fill array Node which defines local node numbers:

    int n, comp, node=0;
    const int nbnodes = NoOfBaseNodes();

    for (n=1; n<=nbnodes; ++n)
      for (comp=1; comp<=nComp; ++comp)  Node(n,comp) = ++node;


    // --    	     the usual initialization:

    material = material0;	

    basicInit();
    setShapeFunctionsAtIPs(nComp);
    compConstantMatrices();
    setPatterns();
}
//-------------------------------------------------------------------------


HQuadMCTetra:: HQuadMCTetra (Material* material0, int nComp0) 

	: HQuadTetra(), nComp(nComp0), 
	  noOfNodes(nComp0*NoOfBaseNodes()), Node(NoOfBaseNodes(),nComp0)
{ 

    // --    fill array Node which defines local node numbers:

    int n, comp, node=0;
    const int nbnodes = NoOfBaseNodes();

    for (n=1; n<=nbnodes; ++n)
      for (comp=1; comp<=nComp; ++comp)  Node(n,comp) = ++node;


    // --    	     the usual initialization:

    material = material0;	

    basicInit();
    setShapeFunctionsAtIPs(nComp);
    compConstantMatrices();
    setPatterns();
}
//-------------------------------------------------------------------------


void HQuadMCTetra:: setPatterns()
{
    int i, j, comp1, comp2, node1, node2;
    const int nbnodes = NoOfBaseNodes();

    StdElement::setPatterns();


    // -- 	set the assembly pattern for DLY:

    DLYPattern = new Matrix<int>(NoOfNodes(),NoOfNodes());
    
    FORALL_ROWS(*DLYPattern,i)
    FORALL_COLUMNS(*DLYPattern,j)  (*DLYPattern)(i,j) = False;
    
    for (comp1=1; comp1<=nComp; ++comp1)
    for (comp2=1; comp2<=nComp; ++comp2)
    {
	for (i=5; i<=nbnodes; ++i)
	{
	    node1 = Node(i,comp1);
	    (*DLYPattern)(node1,node1) = True;
	    
	    for (j=1; j<=4; ++j)
	    {
		node2 = Node(j,comp2);
		(*DLYPattern)(node1,node2) = True;
	    }
	}
    }
}
