<commit_before>/* $Id: Zone.C,v 1.4 2003-01-13 04:35:00 fateneja Exp $ */
/* File sections:
 * Service: constructors, destructors
 * Input: functions directly related to input of data 
 * xCheck: functions directly related to cross-checking the input
 *         against itself for consistency and completeness
 * Preproc: functions directly related to preprocessing of input
 *          prior to solution 
 * Solution: functions directly related to the solution of a (sub)problem
 * Utility: advanced member access such as searching and counting 
 */

#include "Zone.h"
#include "Volume.h"
#include "Loading.h"

/***************************
 ********* Service *********
 **************************/


/** The correct implementation of this operator must ensure that
    previously allocated space is returned to the free store before
    allocating new space into which to copy the object.  It does NOT
    copy 'next'. */
Zone& Zone::operator=(const Zone& z)
{
  if (this == &z)
    return *this;

  boundary = z.boundary;
  nInts = z.nInts;

  return *this;

}

/****************************
 *********** Input **********
 ***************************/

/** It returns a pointer to the newly created zone. */
Zone* Zone::addZone(int ints, double bound)
{
  next = new Zone(bound,ints);
  memCheck(next,"Zone::addZone(...): next");

  verbose(3,"boundary: %g with %d intervals",bound,ints);

  return next;
}


/****************************
 ********* Preproc **********
 ***************************/

/** It does this following setup for calculation of interval volumes
    in Dimension::convert(...). Volume::convert(...) actually
    calculates the volume and generates the Volume object.  The
    arguments are, respsectively, the coordinates of the starting
    point, the ordering of the coordinates, the pointers to the
    appropriate zoneLists, the problem geometry, the list of problem
    material loadings and the problem's list of intervals. */
void Zone::convert(double *start, int *coord, Zone **zoneStart, 
		   Geometry *geom, Loading *loadList, Volume *volList)
{
  
  double d1[3],d2[3],dx[3];
  Loading *loadPtr = loadList->advance();
  Zone* zonePtr[3];
  int inNum[3], nmInts[3];

  /* A: initialize zone pointers */
  zonePtr[2] = zoneStart[2]->next;
  /* B: initialize lower bound */
  d1[2] = start[2];

  /* C: while this dimension has more boundaries */
  while (zonePtr[2] != NULL)
    {
      /* D: initialize upper bound */
      d2[2] = zonePtr[2]->boundary;
      /* E: initialize number of intervals */
      nmInts[2] = zonePtr[2]->nInts;
      /* F: initialize boundary increment */
      dx[2] = (d2[2]-d1[2])/nmInts[2];

      /* G: for each interval in this boundary dimension */
      for (inNum[2]=0;inNum[2]<nmInts[2];inNum[2]++)
	{

	  /* A: see comment A above */
	  zonePtr[1] = zoneStart[1]->next;
	  /* B */
	  d1[1] = start[1];
	  
	  /* C */
	  while (zonePtr[1] != NULL)
	    {
	      /* D */
	      d2[1] = zonePtr[1]->boundary;
	      /* E */
	      nmInts[1] = zonePtr[1]->nInts;
	      /* F */
	      dx[1] = (d2[1]-d1[1])/nmInts[1];

	      /* G */
	      for (inNum[1]=0;inNum[1]<nmInts[1];inNum[1]++)
		{
		 
		  /* A */
		  zonePtr[0] = zoneStart[0]->next;
		  /* B */
		  d1[0] = start[0];

		  /* C */
		  while (zonePtr[0] != NULL)
		    {
		      /* D */
		      d2[0] = zonePtr[0]->boundary;
		      /* E */
		      nmInts[0] = zonePtr[0]->nInts;
		      /* F */
		      dx[0] = (d2[0]-d1[0])/nmInts[0];

		      /* G */
		      for (inNum[0]=0;inNum[0]<nmInts[0];inNum[0]++)
			{
			  /* debug(4,"Creating new interval at point (%g,%g,%g), with size (%g,%g,%g) and coordinate ordering (%d,%d,%d) in zone %s.",
				d1[0],d1[1],d1[2],dx[0],dx[1],dx[2],coord[0],coord[1],coord[2],loadPtr->getName()); */
			  /* calculate volume of this interval */<commit_msg>Fixed bug that cycled through zone loadings too quickly.<commit_after>/* $Id: Zone.C,v 1.5 2009-05-12 20:00:01 wilsonp Exp $ */
/* File sections:
 * Service: constructors, destructors
 * Input: functions directly related to input of data 
 * xCheck: functions directly related to cross-checking the input
 *         against itself for consistency and completeness
 * Preproc: functions directly related to preprocessing of input
 *          prior to solution 
 * Solution: functions directly related to the solution of a (sub)problem
 * Utility: advanced member access such as searching and counting 
 */

#include "Zone.h"
#include "Volume.h"
#include "Loading.h"

/***************************
 ********* Service *********
 **************************/


/** The correct implementation of this operator must ensure that
    previously allocated space is returned to the free store before
    allocating new space into which to copy the object.  It does NOT
    copy 'next'. */
Zone& Zone::operator=(const Zone& z)
{
  if (this == &z)
    return *this;

  boundary = z.boundary;
  nInts = z.nInts;

  return *this;

}

/****************************
 *********** Input **********
 ***************************/

/** It returns a pointer to the newly created zone. */
Zone* Zone::addZone(int ints, double bound)
{
  next = new Zone(bound,ints);
  memCheck(next,"Zone::addZone(...): next");

  verbose(3,"boundary: %g with %d intervals",bound,ints);

  return next;
}


/****************************
 ********* Preproc **********
 ***************************/

/** It does this following setup for calculation of interval volumes
    in Dimension::convert(...). Volume::convert(...) actually
    calculates the volume and generates the Volume object.  The
    arguments are, respsectively, the coordinates of the starting
    point, the ordering of the coordinates, the pointers to the
    appropriate zoneLists, the problem geometry, the list of problem
    material loadings and the problem's list of intervals. */
void Zone::convert(double *start, int *coord, Zone **zoneStart, 
		   Geometry *geom, Loading *loadList, Volume *volList)
{
  
  double d1[3],d2[3],dx[3];
  Loading *loadPtr = loadList->advance();
  Loading *firstLoadPtr[3];
  Zone* zonePtr[3];
  int inNum[3], nmInts[3];

  /* A: initialize zone pointers */
  zonePtr[2] = zoneStart[2]->next;
  /* B: initialize lower bound */
  d1[2] = start[2];

  /* C: while this dimension has more boundaries */
  while (zonePtr[2] != NULL)
    {
      /* D: initialize upper bound */
      d2[2] = zonePtr[2]->boundary;
      /* E: initialize number of intervals */
      nmInts[2] = zonePtr[2]->nInts;
      /* F: initialize boundary increment */
      dx[2] = (d2[2]-d1[2])/nmInts[2];

      /* store the pointer to the first loading in this dimension */
      firstLoadPtr[2] = loadPtr;

      /* G: for each interval in this boundary dimension */
      for (inNum[2]=0;inNum[2]<nmInts[2];inNum[2]++)
	{

	  /* always start at the first loading definition of this row */
	  loadPtr = firstLoadPtr[2];

	  /* A: see comment A above */
	  zonePtr[1] = zoneStart[1]->next;
	  /* B */
	  d1[1] = start[1];
	  
	  /* C */
	  while (zonePtr[1] != NULL)
	    {
	      /* D */
	      d2[1] = zonePtr[1]->boundary;
	      /* E */
	      nmInts[1] = zonePtr[1]->nInts;
	      /* F */
	      dx[1] = (d2[1]-d1[1])/nmInts[1];

	      /* store the pointer to the first loading in this dimension */
	      firstLoadPtr[1] = loadPtr;

	      /* G */
	      for (inNum[1]=0;inNum[1]<nmInts[1];inNum[1]++)
		{
		  /* always start at the first loading definition of this row */
		  loadPtr = firstLoadPtr[1];

		  /* A */
		  zonePtr[0] = zoneStart[0]->next;
		  /* B */
		  d1[0] = start[0];

		  /* C */
		  while (zonePtr[0] != NULL)
		    {
		      /* D */
		      d2[0] = zonePtr[0]->boundary;
		      /* E */
		      nmInts[0] = zonePtr[0]->nInts;
		      /* F */
		      dx[0] = (d2[0]-d1[0])/nmInts[0];

		      /* G */
		      for (inNum[0]=0;inNum[0]<nmInts[0];inNum[0]++)
			{
			  /* debug(4,"Creating new interval at point (%g,%g,%g), with size (%g,%g,%g) and coordinate ordering (%d,%d,%d) in zone %s.",
				d1[0],d1[1],d1[2],dx[0],dx[1],dx[2],coord[0],coord[1],coord[2],loadPtr->getName()); */
			  /* calculate volume of this interval */
{'fraction_non_alphanumeric': 0.200616522811344, 'fraction_numerical': 0.02626387176325524, 'mean_word_length': 2.972086190009794, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7272946', 'n_tokens_mistral': 2859, 'n_tokens_neox': 2599, 'n_words': 758}