コード例 #1
0
ファイル: sysUtils.c プロジェクト: timburrow/ovj3
/*
 * returns the deltatime and total time from the updateTimeStamp() calls
 * roughly 4 usec to execute
*/
double getTimeStampDurations(double *deltatime, double *durationtime)
{

    double temp;
    *deltatime = deltaTime(currentTimeStamp,prevTimeStamp);
    *durationtime = deltaTime(currentTimeStamp,initialTimeStamp);
    // *durationtime = ((double)(DurationTimeStamp))/333.3 ;
    // diagPrint(debugInfo,"getTimeStampDurations: duration: %lf vs %lf usec\n",temp,*durationtime);

    return (*deltatime);
}
コード例 #2
0
ファイル: timer.cpp プロジェクト: TheSkyCrasher/ENOJ2
void Timer::Update()
{
	m_deltaTime = 0.0f;
	QueryPerformanceFrequency((LARGE_INTEGER*)&m_freq);
	QueryPerformanceCounter((LARGE_INTEGER*)&m_currentFrame);
	int deltaTicks = (int)(m_currentFrame - m_prevFrame);
	m_deltaTime = (float)deltaTicks / (float)m_freq;
	m_prevFrame = m_currentFrame;

	m_frames += deltaTime();
	if (m_frames >= 1.0f)
	{
		std::cout << std::setprecision(3) << 1.0f / deltaTime() << " fps" << std::endl;
		m_frames = 0;
	}
}
コード例 #3
0
ファイル: Holder.cpp プロジェクト: FRCTeam159/2016-Robot-Code
//===========================================
//void Holder::WaitForBallToLeave
//===========================================
//- This State machine state : WAIT_FOR_BALL_TO_LEAVE
//- Caller state machine state : WAIT_FOR_PUSH_REQUEST
//- Wait for the IR sensor to stop detecting the ball
//  then end ftime function, and use output as a delay
//- Set gateMotor to reverse speed
//===========================================
void Holder::WaitForBallToLeave(){
	ftime(&end_time);
	double delt=deltaTime(&start_time, &end_time);
	//printf("WAIT_FOR_BALL_TO_LEAVE ball is not detected delt=%g\n",delt);
	if(delt >= ballDetectionDelay){
		int ballDetected = !IRsensor.Get();
		if(ballDetected)
		{
			pushComplete = PUSH_ERROR;
			std::cout<<"Holder: push failed!"<<std::endl;
			SetPushMotorSpeed(.3);
			gateMotor.Set(-.35);
			state= BALL_PUSH_ERR;
		}
		else
		{
			pushComplete = PUSH_COMPLETE;
			printf("going to reverse limit\n");
			SetPushMotorSpeed(0);
			gateMotor.Set(-GATEMOTORSPEED);
			state=GO_TO_REVERSE_LIMIT;
			//gateMotor.Set(0);
			//Wait(ballDetectionDelay);
			//gateMotor.SetPID(P,I,D);
			//gateMotor.SetPosition(FORWARDLIMITPOSITION);
			//gateMotor.Set(0);
		}


	}
}
コード例 #4
0
ファイル: main.c プロジェクト: slaeshjag/Muon
int main(int argc, char **argv) {
	int port, gamespeed;

	if (argc < 4) {
		fprintf(stdout, "Usage: %s <map> <gamespeed (1-10)> <players> [port]\n", argv[0]);
		return -1;
	}

	if (argc >= 5)
		port = atoi(argv[4]);
	else
		port = SERVER_PORT_DEFAULT;

	fprintf(stderr, "Listening on port %i...\n", port);
	server_init();
	gettimeofday(&time_d, NULL);
	gamespeed = atoi(argv[2]);

	if (server_start(argv[1], atoi(argv[3]), port, gamespeed) == NULL)
		return -1;
	for (;;) {
		server_loop(deltaTime());
		#ifdef _WIN32
		Sleep(15);
		#else
		usleep(15000);
		#endif
	}

	
	return 0;
}
コード例 #5
0
ファイル: test.cpp プロジェクト: hellovai/cs378-update
void runDijkstra(Graph* g, int num_threads, std::string name, int source = 0) {
  struct timeval t1, t2;
  std::cout << "----" << name << "----" << std::endl;

  int* dist = new int[g->size];
  for (int i = 0; i < g->size; ++i) {
    dist[i] = INT_MAX;
  }

  // init
  T q;
  dist[source] = 0;
  QueueType temp = {source, 0};
  q.push(temp);

  std::vector<std::thread> v;
  for (int i = 0; i < num_threads; i++) {
    v.push_back(std::thread(dijkstra<T>, g, dist, q));
  }

  gettimeofday(&t1, 0);
  for (int i = 0; i < num_threads; i++) {
    v[i].join();
  }
  gettimeofday(&t2, 0);
  printf("Time:\t%f\n", deltaTime(t1, t2));

  delete dist;
}
コード例 #6
0
ファイル: AMP_Time_Def.hpp プロジェクト: SailingFM/Albany
void Time<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  time(0) = workset.current_time;

  Albany::MDArray timeOld = (*workset.stateArrayPtr)[timeName];
  deltaTime(0) = time(0) - timeOld(0);
}
コード例 #7
0
	void mover(float a, float b) {
		x += a * deltaTime();
		y += b* deltaTime();
		if (x < limites.left) {
			x = limites.left;
		}
		if (x > limites.right) {
			x = limites.right;
		}
		if (y < limites.bottom) {
			y = limites.bottom;
		}
		if (y > limites.top) {
			y = limites.top;
		}
		
	}
コード例 #8
0
	void mover(float n) {
		if (activo) {
			x -= n*deltaTime();
			if (x < limites.left - 1) {
				activo = false;
			}
		}
	}
コード例 #9
0
  void SurfaceTLPoroMassResidual<EvalT, Traits>::
  evaluateFields(typename Traits::EvalData workset)
  {
    typedef Intrepid::FunctionSpaceTools FST;
    typedef Intrepid::RealSpaceTools<ScalarT> RST;

    Albany::MDArray porePressureold = (*workset.stateArrayPtr)[porePressureName];
    Albany::MDArray Jold;
    if (haveMech) {
      Jold = (*workset.stateArrayPtr)[JName];
    }

    ScalarT dt = deltaTime(0);

        // Compute pore fluid flux
       if (haveMech) {
       	// Put back the permeability tensor to the reference configuration
    	    RST::inverse(F_inv, defGrad);
           RST::transpose(F_invT, F_inv);
           FST::scalarMultiplyDataData<ScalarT>(JF_invT, J, F_invT);
           FST::scalarMultiplyDataData<ScalarT>(KJF_invT, kcPermeability, JF_invT);
           FST::tensorMultiplyDataData<ScalarT>(Kref, F_inv, KJF_invT);
           FST::tensorMultiplyDataData<ScalarT> (flux, Kref, scalarGrad); // flux_i = k I_ij p_j
       } else {
           FST::scalarMultiplyDataData<ScalarT> (flux, kcPermeability, scalarGrad); // flux_i = kc p_i
       }

       for (std::size_t cell=0; cell < workset.numCells; ++cell){
             for (std::size_t qp=0; qp < numQPs; ++qp) {
               for (std::size_t dim=0; dim <numDims; ++dim){

                 fluxdt(cell, qp, dim) = -flux(cell,qp,dim)*dt*refArea(cell,qp)*thickness;
               }
             }
       }
          FST::integrate<ScalarT>(poroMassResidual, fluxdt,
          		surface_Grad_BF, Intrepid::COMP_CPP, false); // "true" sums into

    for (std::size_t cell(0); cell < workset.numCells; ++cell) {
      for (std::size_t node(0); node < numPlaneNodes; ++node) {
        // initialize the residual
        int topNode = node + numPlaneNodes;

        for (std::size_t pt=0; pt < numQPs; ++pt) {

          // If there is no diffusion, then the residual defines only on the mid-plane value

          // Local Rate of Change volumetric constraint term
           poroMassResidual(cell, node) -=
                         refValues(node,pt)*(
                         std::log(J(cell,pt)/Jold(cell, pt))*
                         biotCoefficient(cell,pt) +
                          (porePressure(cell, pt) - porePressureold(cell, pt))/ biotModulus(cell,pt)
                          ) *refArea(cell,pt)*thickness;

           poroMassResidual(cell, topNode) -=
        		           refValues(node,pt)*(
        		           std::log(J(cell,pt)/Jold(cell, pt))*
        		           biotCoefficient(cell,pt) +
        		           (porePressure(cell, pt) - porePressureold(cell, pt))/ biotModulus(cell,pt)
        		           ) *refArea(cell,pt)*thickness;



        } // end integrartion point loop
      } //  end plane node loop

      // Stabilization term (if needed)
    } // end cell loop




  }
コード例 #10
0
void Parallax() {

	glEnable(GL_TEXTURE_2D);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_NOTEQUAL, 0);

	glDisable(GL_LIGHTING);

	glColor3f(1.0, 1.0, 1.0);

	glLoadIdentity();

	p1 += 0.0004f* deltaTime();
	glBindTexture(GL_TEXTURE_2D, tex1);

	glBegin(GL_QUADS);
	glTexCoord2f(0.5 + p1, 0);
	glVertex3f(limites.right, limites.top, -3);

	glTexCoord2f(0 + p1, 0);
	glVertex3f(limites.left, limites.top, -3);

	glTexCoord2f(0 + p1, 1.0);
	glVertex3f(limites.left, limites.bottom, -3);

	glTexCoord2f(0.5 + p1, 1.0);
	glVertex3f(limites.right, limites.bottom, -3);
	glEnd();

	//2
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glLoadIdentity();

	p2 += 0.00006f * deltaTime();
	glBindTexture(GL_TEXTURE_2D, tex2);

	glBegin(GL_QUADS);
	glTexCoord2f(0.5 + p2, 0);
	glVertex3f(limites.right, limites.top, -2);

	glTexCoord2f(0 + p2, 0);
	glVertex3f(limites.left, limites.top, -2);

	glTexCoord2f(0 + p2, 1.0);
	glVertex3f(limites.left, limites.bottom, -2);

	glTexCoord2f(0.5 + p2, 1.0);
	glVertex3f(limites.right, limites.bottom, -2);
	glEnd();

	//3
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glLoadIdentity();

	p3 += 0.00002f * deltaTime();

	glBindTexture(GL_TEXTURE_2D, tex3);

	glBegin(GL_QUADS);
	glTexCoord2f(0.5 + p3, 0);
	glVertex3f(limites.right, limites.top, -1);

	glTexCoord2f(0 + p3, 0);
	glVertex3f(limites.left, limites.top, -1);

	glTexCoord2f(0 + p3, 1.0);
	glVertex3f(limites.left, limites.bottom, -1);

	glTexCoord2f(0.5 + p3, 1.0);
	glVertex3f(limites.right, limites.bottom, -1);
	glEnd();
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	glDisable(GL_ALPHA_TEST);
}
コード例 #11
0
	void mover(GLfloat m) {
		x += m* deltaTime();
		if (x > limites.right + 1) {
			activo = false;
		}
	}
コード例 #12
0
	void mover(GLfloat m) {
		x -= m*deltaTime();
		if (x < limites.left - 1) {
			activo = false;
		}
	}
コード例 #13
0
ファイル: Base3DView.cpp プロジェクト: kkaushalp/aphid
float Base3DView::frameRate()
{ return 1000.f/deltaTime(); }
コード例 #14
0
ファイル: PhaseResidual_Def.hpp プロジェクト: gahansen/Albany
  void PhaseResidual<EvalT, Traits>::
  evaluateFields(typename Traits::EvalData workset)
  {
    // time step
    ScalarT dt = deltaTime(0);
    typedef Intrepid2::FunctionSpaceTools<PHX::Device> FST;

    if (dt == 0.0) dt = 1.0e-15;
    //grab old temperature
    Albany::MDArray T_old = (*workset.stateArrayPtr)[Temperature_Name_];
    
    // Compute Temp rate
    for (std::size_t cell = 0; cell < workset.numCells; ++cell)
      {
        for (std::size_t qp = 0; qp < num_qps_; ++qp)
	  {
            T_dot_(cell, qp) = (T_(cell, qp) - T_old(cell, qp)) / dt;
	  }
      }

    // diffusive term
    FST::scalarMultiplyDataData<ScalarT> (term1_, k_.get_view(), T_grad_.get_view());
    // FST::integrate(residual_, term1_, w_grad_bf_, false);
    //Using for loop to calculate the residual 

    
    // zero out residual
    for (int cell = 0; cell < workset.numCells; ++cell) {
      for (int node = 0; node < num_nodes_; ++node) {
        residual_(cell,node) = 0.0;
      }
    }

    //    for (int cell = 0; cell < workset.numCells; ++cell) {
    //      for (int qp = 0; qp < num_qps_; ++qp) {
    //        for (int node = 0; node < num_nodes_; ++node) {
    //          for (int i = 0; i < num_dims_; ++i) {
    //             residual_(cell,node) += w_grad_bf_(cell,node,qp,i) * term1_(cell,qp,i);
    //          }
    //        }
    //      }
    //    }

    //THESE ARE HARD CODED NOW. NEEDS TO BE CHANGED TO USER INPUT LATER
    ScalarT Coeff_volExp = 65.2e-6; //per kelvins
    ScalarT Ini_temp = 300; //kelvins
   
    if (hasConsolidation_) {
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    //Use if consolidation and expansion is considered
	    //  porosity_function1 = pow(	((1.0 - porosity_(cell, qp)) / ((1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity))), 2);
	    //  porosity_function2 = (1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
	                    
	    //Use if only consolidation is considered
	    porosity_function1 = pow(	((1.0 - porosity_(cell, qp)) / (1.0 - Initial_porosity)), 2);
	    porosity_function2 = (1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));					
												
	    //In the model that is currently used, the Z-axis corresponds to the depth direction. Hence the term porosity
	    //function1 is multiplied with the second term. 
	    residual_(cell, node) += porosity_function2 * (
							   w_grad_bf_(cell, node, qp, 0) * term1_(cell, qp, 0)
							   + w_grad_bf_(cell, node, qp, 1) * term1_(cell, qp, 1)
							   + porosity_function1 * w_grad_bf_(cell, node, qp, 2) * term1_(cell, qp, 2));
	  }
	}
      }

      // heat source from laser 
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    //Use if consolidation and expansion is considered
	    //  porosity_function2 = (1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    //Use if only consolidation is considered
	    porosity_function2 = (1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));

	    residual_(cell, node) -= porosity_function2 * (w_bf_(cell, node, qp) * laser_source_(cell, qp));
	  }
	}
      }

      // all other problem sources
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    //Use if consolidation and expansion is considered
	    //  porosity_function2 = (1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    //Use if only consolidation is considered
	    porosity_function2 = (1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    residual_(cell, node) -= porosity_function2 * (w_bf_(cell, node, qp) * source_(cell, qp));
	  }
	}
      }

      // transient term
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    //Use if consolidation and expansion is considered
	    //  porosity_function2 = (1+Coeff_volExp*(T_(cell,qp) -Ini_temp))*(1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    //Use if only consolidation is considered
	    porosity_function2 = (1.0 - Initial_porosity) / (1.0 - porosity_(cell, qp));
						
	    residual_(cell, node) += porosity_function2 * (w_bf_(cell, node, qp) * energyDot_(cell, qp));
	  }
	}
      }
    } else { // does not have consolidation
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    residual_(cell, node) += (
				      w_grad_bf_(cell, node, qp, 0) * term1_(cell, qp, 0)
				      + w_grad_bf_(cell, node, qp, 1) * term1_(cell, qp, 1)
				      + w_grad_bf_(cell, node, qp, 2) * term1_(cell, qp, 2));
	  }
	}
      }
      // heat source from laser 
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    residual_(cell, node) -= (w_bf_(cell, node, qp) * laser_source_(cell, qp));
	  }
	}
      }
      // all other problem sources
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    residual_(cell, node) -= (w_bf_(cell, node, qp) * source_(cell, qp));
	  }
	}
      }
      // transient term
      for (int cell = 0; cell < workset.numCells; ++cell) {
	for (int qp = 0; qp < num_qps_; ++qp) {
	  for (int node = 0; node < num_nodes_; ++node) {
	    residual_(cell, node) += (w_bf_(cell, node, qp) * energyDot_(cell, qp));
	  }
	}
      }
    }
         
    // heat source from laser 
    //PHAL::scale(laser_source_, -1.0);
    //FST::integrate(residual_, laser_source_, w_bf_, true);

    // all other problem sources
    //PHAL::scale(source_, -1.0);
    //FST::integrate(residual_, source_, w_bf_, true);

    // transient term
    //FST::integrate(residual_, energyDot_, w_bf_, true);
  }
コード例 #15
0
void ThermoMechanicalEnergyResidual<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  bool print = false;
  //if (typeid(ScalarT) == typeid(RealType)) print = true;

  // alias the function space tools
  typedef Intrepid2::FunctionSpaceTools FST;

  // get old temperature
  Albany::MDArray Temperature_old = (*workset.stateArrayPtr)[tempName];

  // time step
  ScalarT dt = deltaTime(0);

  // compute the 'material' flux
  FST::tensorMultiplyDataData<ScalarT> (C, F, F, 'T');
  Intrepid2::RealSpaceTools<ScalarT>::inverse(Cinv, C);
  FST::tensorMultiplyDataData<ScalarT> (CinvTgrad, Cinv, TGrad);
  FST::scalarMultiplyDataData<ScalarT> (flux, ThermalCond, CinvTgrad);

   FST::integrate<ScalarT>(TResidual, flux, wGradBF, Intrepid2::COMP_CPP, false); // "false" overwrites

  if (haveSource) {
    for (int i=0; i<Source.dimension(0); i++) 
       for (int j=0; j<Source.dimension(1); j++) 
          Source(i,j) *= -1.0;
     FST::integrate<ScalarT>(TResidual, Source, wBF, Intrepid2::COMP_CPP, true); // "true" sums into
  }

 for (int i=0; i<mechSource.dimension(0); i++) 
       for (int j=0; j<mechSource.dimension(1); j++)
           mechSource(i,j) *= -1.0;
    FST::integrate<ScalarT>(TResidual, mechSource, wBF, Intrepid2::COMP_CPP, true); // "true" sums into


//Irina comment: code below was commented out
  //if (workset.transientTerms && enableTransient)
  //   FST::integrate<ScalarT>(TResidual, Tdot, wBF, Intrepid2::COMP_CPP, true); // "true" sums into
  //
  // compute factor
  ScalarT fac(0.0);
  if (dt > 0.0)
    fac = ( density * Cv ) / dt;

  for (int cell=0; cell < workset.numCells; ++cell)
    for (int qp=0; qp < numQPs; ++qp)
      Tdot(cell,qp) = fac * ( Temperature(cell,qp) - Temperature_old(cell,qp) );
   FST::integrate<ScalarT>(TResidual, Tdot, wBF, Intrepid2::COMP_CPP, true); // "true" sums into

  if (print)
  {
    std::cout << " *** ThermoMechanicalEnergyResidual *** " << std::endl;
    std::cout << "  **   dt: " << dt << std::endl;
    std::cout << "  **  rho: " << density << std::endl;
    std::cout << "  **   Cv: " << Cv << std::endl;
    for (unsigned int cell(0); cell < workset.numCells; ++cell)
    {
      std::cout << "  ** Cell: " << cell << std::endl;
      for (unsigned int qp(0); qp < numQPs; ++qp)
      {
        std::cout << "   * QP: " << std::endl;
       std::cout << "    F   : ";
       for (unsigned int i(0); i < numDims; ++i)
         for (unsigned int j(0); j < numDims; ++j)
           std::cout << F(cell,qp,i,j) << " ";
       std::cout << std::endl;

        std::cout << "    C   : ";
        for (unsigned int i(0); i < numDims; ++i)
          for (unsigned int j(0); j < numDims; ++j)
            std::cout << C(cell,qp,i,j) << " ";
        std::cout << std::endl;

        std::cout << "    T   : " << Temperature(cell,qp) << std::endl;
        std::cout << "    Told: " << Temperature(cell,qp) << std::endl;
        std::cout << "    k   : " << ThermalCond(cell,qp) << std::endl;
      }
    }
  }
}
コード例 #16
0
  void SurfaceTLPoroMassResidual<EvalT, Traits>::
  evaluateFields(typename Traits::EvalData workset)
  {
    typedef Intrepid::FunctionSpaceTools FST;
    typedef Intrepid::RealSpaceTools<ScalarT> RST;

    Albany::MDArray porePressureold = (*workset.stateArrayPtr)[porePressureName];
    Albany::MDArray Jold;
    if (haveMech) {
      Jold = (*workset.stateArrayPtr)[JName];
    }

    ScalarT dt = deltaTime(0);

    // THE INTREPID REALSPACE TOOLS AND FUNCTION SPACE TOOLS NEED TO BE REMOVED!!!
    // Compute pore fluid flux
    if (haveMech) {
      // Put back the permeability tensor to the reference configuration
      RST::inverse(F_inv, defGrad);
      RST::transpose(F_invT, F_inv);
       FST::scalarMultiplyDataData<ScalarT>(JF_invT, J, F_invT);
       FST::scalarMultiplyDataData<ScalarT>(KJF_invT, kcPermeability, JF_invT);
      FST::tensorMultiplyDataData<ScalarT>(Kref, F_inv, KJF_invT);
      FST::tensorMultiplyDataData<ScalarT> (flux, Kref, scalarGrad); // flux_i = k I_ij p_j
    } else {
       FST::scalarMultiplyDataData<ScalarT> (flux, kcPermeability, scalarGrad); // flux_i = kc p_i
    }

    for (int cell(0); cell < workset.numCells; ++cell) {
      for (int node(0); node < numPlaneNodes; ++node) {
        // initialize the residual
        int topNode = node + numPlaneNodes;
        poroMassResidual(cell, topNode)  = 0.0;
        poroMassResidual(cell, node)  = 0.0;
      }
    }
 
    for (int cell(0); cell < workset.numCells; ++cell) {
      for (int node(0); node < numPlaneNodes; ++node) {
        int topNode = node + numPlaneNodes;

        for (int pt=0; pt < numQPs; ++pt) {

          // If there is no diffusion, then the residual defines only on the mid-plane value

          // Local Rate of Change volumetric constraint term
          poroMassResidual(cell, node) -= refValues(node,pt)*
            (std::log(J(cell,pt)/Jold(cell, pt))*
                     biotCoefficient(cell,pt) +
                     (porePressure(cell, pt) - porePressureold(cell, pt))/
                     biotModulus(cell,pt))*refArea(cell,pt);

          poroMassResidual(cell, topNode) -= refValues(node,pt)*
            (std::log(J(cell,pt)/Jold(cell, pt))*
                     biotCoefficient(cell,pt) +
                     (porePressure(cell, pt) - porePressureold(cell, pt))/
                     biotModulus(cell,pt))*refArea(cell,pt);

        } // end integrartion point loop
      } //  end plane node loop
    } // end cell loop


    for (int cell(0); cell < workset.numCells; ++cell) {
      for (int node(0); node < numPlaneNodes; ++node) {

        int topNode = node + numPlaneNodes;

        for (int pt=0; pt < numQPs; ++pt) {
          for (int dim=0; dim <numDims; ++dim){

            poroMassResidual(cell,node) -=  flux(cell, pt, dim)*dt*
              surface_Grad_BF(cell, node, pt, dim)*
              refArea(cell,pt);

            poroMassResidual(cell, topNode) -= flux(cell, pt, dim)*dt*
              surface_Grad_BF(cell, topNode, pt, dim)*
              refArea(cell,pt);
          }
        }
      }
    }

  }
コード例 #17
0
void UnSatPoroElasticityResidMass<EvalT, Traits>::
evaluateFields(typename Traits::EvalData workset)
{
  typedef Intrepid::FunctionSpaceTools FST;


  Albany::MDArray strainold = (*workset.stateArrayPtr)[strainName];
  Albany::MDArray porosityold = (*workset.stateArrayPtr)[porosityName];
  Albany::MDArray porePressureold = (*workset.stateArrayPtr)[porePressureName];
  Albany::MDArray vgSatold = (*workset.stateArrayPtr)[satName];

  // Set Warning message
  if (porosityold(1,1) < 0 || porosity(1,1) < 0 ) {
    std::cout << "negative porosity detected. Error! \n";
  }

  switch (numDims) {
  case 3:

	  // Pore-fluid diffusion coupling.
	  for (std::size_t cell=0; cell < workset.numCells; ++cell) {

		  for (std::size_t node=0; node < numNodes; ++node) {
			  TResidual(cell,node)=0.0;
			  for (std::size_t qp=0; qp < numQPs; ++qp) {

				  // Transient partial saturated flow
				  ScalarT trstrain = 0.0;
				  for (std::size_t i(0); i < numDims; ++i){
					  trstrain += strainold(cell,qp,i,i);
				  }
				  // Volumetric Constraint Term
				  TResidual(cell,node) += -vgSat(cell, qp)*(

						  strain(cell,qp,0,0) + strain(cell,qp,1,1)+strain(cell,qp,2,2) - trstrain
						  )
            		  *wBF(cell, node, qp)  ;

				  // Pore-fluid Resistance Term
				  TResidual(cell,node) +=  -porosity(cell,qp)*(
						                   vgSat(cell, qp) -vgSatold(cell, qp)
						                  )*wBF(cell, node, qp);

			  }
		  }
	  }
	  break;
  case 2:
	  // Pore-fluid diffusion coupling.
	  for (std::size_t cell=0; cell < workset.numCells; ++cell) {

		  for (std::size_t node=0; node < numNodes; ++node) {
			  TResidual(cell,node)=0.0;
			  for (std::size_t qp=0; qp < numQPs; ++qp) {

				  // Transient partial saturated flow
				  ScalarT trstrain = 0.0;
				  for (std::size_t i(0); i < numDims; ++i){
					  trstrain += strainold(cell,qp,i,i);
				  }
				  // Volumetric Constraint Term
				  TResidual(cell,node) += -vgSat(cell, qp)*(
					              	  strain(cell,qp,0,0) + strain(cell,qp,1,1) - trstrain
						              )*wBF(cell, node, qp)  ;

				  // Pore-fluid Resistance Term
				  TResidual(cell,node) +=  -porosity(cell,qp)*(vgSat(cell, qp)
						                   -vgSatold(cell, qp)
						                  )*wBF(cell, node, qp);
			  }
		  }
	  }
	  break;
  case 1:
	  // Pore-fluid diffusion coupling.
	  	  for (std::size_t cell=0; cell < workset.numCells; ++cell) {

	  		  for (std::size_t node=0; node < numNodes; ++node) {
	  			  TResidual(cell,node)=0.0;
	  			  for (std::size_t qp=0; qp < numQPs; ++qp) {

	  				  // Transient partial saturated flow
	  				  ScalarT trstrain = 0.0;
	  				  for (std::size_t i(0); i < numDims; ++i){
	  					  trstrain += strainold(cell,qp,i,i);
	  				  }
	  				  // Volumetric Constraint Term
	  				  TResidual(cell,node) += -vgSat(cell, qp)*(
	  					              	  strain(cell,qp,0,0) - trstrain
	  						              )*wBF(cell, node, qp)  ;

	  				  // Pore-fluid Resistance Term
	  				  TResidual(cell,node) +=  -(vgSat(cell, qp)
	  						                   -vgSatold(cell, qp)
	  						                  )*porosity(cell, qp)*
	              		                    		wBF(cell, node, qp);
	  			  }
	  		  }
	  	  }
	  	  break;

   }


  // Pore-Fluid Diffusion Term

   ScalarT dt = deltaTime(0);

   FST::scalarMultiplyDataData<ScalarT> (flux, vgPermeability, TGrad); // flux_i = k I_ij p_j

   for (std::size_t cell=0; cell < workset.numCells; ++cell){
      for (std::size_t qp=0; qp < numQPs; ++qp) {
    	  for (std::size_t dim=0; dim <numDims; ++dim){
    		  fluxdt(cell, qp, dim) = -flux(cell,qp,dim)*dt; // should replace the number with dt
    	  }
      }
  }


  FST::integrate<ScalarT>(TResidual, fluxdt, wGradBF, Intrepid::COMP_CPP, true); // "true" sums into




  //---------------------------------------------------------------------------//
  // Stabilization Term (only 2D and 3D problem need stabilizer)

// Penalty Term

  for (std::size_t cell=0; cell < workset.numCells; ++cell){

   porePbar = 0.0;

   vol = 0.0;
   for (std::size_t qp=0; qp < numQPs; ++qp) {
	porePbar += weights(cell,qp)*(vgSat(cell,qp)
			                     -vgSatold(cell, qp)
			                      );

	vol  += weights(cell,qp);
   }
   porePbar  /= vol;

   for (std::size_t qp=0; qp < numQPs; ++qp) {
	   pterm(cell,qp) = porePbar;
   }

   for (std::size_t node=0; node < numNodes; ++node) {
	     trialPbar = 0.0;
 		 for (std::size_t qp=0; qp < numQPs; ++qp) {
 			  trialPbar += wBF(cell,node,qp);
 		 }
 		 trialPbar /= vol;
 //		 for (std::size_t qp=0; qp < numQPs; ++qp) {
 //		 		   tpterm(cell,node,qp) = trialPbar;
//		 }

   }

 }


  for (std::size_t cell=0; cell < workset.numCells; ++cell) {

	  for (std::size_t node=0; node < numNodes; ++node) {
		  for (std::size_t qp=0; qp < numQPs; ++qp) {

 				  TResidual(cell,node) -= (vgSat(cell, qp)
 						                  -vgSatold(cell, qp)
 						                               )
                    		                    		*stabParameter(cell, qp)*porosity(cell, qp)*
                    		                    		( wBF(cell, node, qp)
                    		                    	//			-tpterm(cell,node,q	)
                    		                    				);
 				  TResidual(cell,node) += pterm(cell,qp)*stabParameter(cell, qp)*porosity(cell, qp)*
 						 ( wBF(cell, node, qp)
 						//		 -tpterm(cell,node,qps )
 								 );






		  }
	  }
  }






}
コード例 #18
0
  void TLPoroPlasticityResidMass<EvalT, Traits>::
  evaluateFields(typename Traits::EvalData workset)
  {
    bool print = false;
    //if (typeid(ScalarT) == typeid(RealType)) print = true;

    typedef Intrepid::FunctionSpaceTools FST;
    typedef Intrepid::RealSpaceTools<ScalarT> RST;

    // Use previous time step for Backward Euler Integration
    Albany::MDArray porePressureold
      = (*workset.stateArrayPtr)[porePressureName];

    Albany::MDArray Jold;
    if (haveMechanics) {
      Jold = (*workset.stateArrayPtr)[JName];
    } 

    // Pore-fluid diffusion coupling.
    for (std::size_t cell=0; cell < workset.numCells; ++cell) {
      for (std::size_t node=0; node < numNodes; ++node) {
        TResidual(cell,node)=0.0;
        for (std::size_t qp=0; qp < numQPs; ++qp) {

          // Volumetric Constraint Term
          if (haveMechanics)  {
            TResidual(cell,node) -= biotCoefficient(cell, qp)
              * (std::log(J(cell,qp)/Jold(cell,qp)))
              * wBF(cell, node, qp) ;
          }

          // Pore-fluid Resistance Term
          TResidual(cell,node) -=  ( porePressure(cell,qp)-porePressureold(cell, qp) )
            / biotModulus(cell, qp)*wBF(cell, node, qp);

        }
      }
    }
    // Pore-Fluid Diffusion Term

    ScalarT dt = deltaTime(0);

    if (haveMechanics) {
      RST::inverse(F_inv, defgrad);
      RST::transpose(F_invT, F_inv);
      FST::scalarMultiplyDataData<ScalarT>(JF_invT, J, F_invT);
      FST::scalarMultiplyDataData<ScalarT>(KJF_invT, kcPermeability, JF_invT);
      FST::tensorMultiplyDataData<ScalarT>(Kref, F_inv, KJF_invT);
      FST::tensorMultiplyDataData<ScalarT> (flux, Kref, TGrad); // flux_i = k I_ij p_j
    } else {
      FST::scalarMultiplyDataData<ScalarT> (flux, kcPermeability, TGrad); // flux_i = kc p_i
    }

    for (std::size_t cell=0; cell < workset.numCells; ++cell){
      for (std::size_t qp=0; qp < numQPs; ++qp) {
        for (std::size_t dim=0; dim <numDims; ++dim){
          fluxdt(cell, qp, dim) = -flux(cell,qp,dim)*dt;
        }
      }
    }
    FST::integrate<ScalarT>(TResidual, fluxdt,
                            wGradBF, Intrepid::COMP_CPP, true); // "true" sums into

    //---------------------------------------------------------------------------//
    // Stabilization Term

    for (std::size_t cell=0; cell < workset.numCells; ++cell){

      porePbar = 0.0;
      vol = 0.0;
      for (std::size_t qp=0; qp < numQPs; ++qp) {
        porePbar += weights(cell,qp)
          * (porePressure(cell,qp)-porePressureold(cell, qp) );
        vol  += weights(cell,qp);
      }
      porePbar /= vol;
      for (std::size_t qp=0; qp < numQPs; ++qp) {
        pterm(cell,qp) = porePbar;
      }

      for (std::size_t node=0; node < numNodes; ++node) {
        trialPbar = 0.0;
        for (std::size_t qp=0; qp < numQPs; ++qp) {
          trialPbar += wBF(cell,node,qp);
        }
        trialPbar /= vol;
        for (std::size_t qp=0; qp < numQPs; ++qp) {
          tpterm(cell,node,qp) = trialPbar;
        }

      }

    }
    ScalarT temp(0);

    for (std::size_t cell=0; cell < workset.numCells; ++cell) {

      for (std::size_t node=0; node < numNodes; ++node) {
        for (std::size_t qp=0; qp < numQPs; ++qp) {

          temp = 3.0 - 12.0*kcPermeability(cell,qp)*dt
            /(elementLength(cell,qp)*elementLength(cell,qp));

          //if ((temp > 0) & stabParameter(cell,qp) > 0) {
          if ((temp > 0) & stab_param_ > 0) {

            TResidual(cell,node) -= 
              ( porePressure(cell,qp)-porePressureold(cell, qp) )
              //* stabParameter(cell, qp)
              * stab_param_
              * std::abs(temp) // should be 1 but use 0.5 for safety
              * (0.5 + 0.5*std::tanh( (temp-1)/kcPermeability(cell,qp)  ))
              / biotModulus(cell, qp)
              * ( wBF(cell, node, qp)
                // -tpterm(cell,node,qp)
                );
            TResidual(cell,node) += pterm(cell,qp)
              //* stabParameter(cell, qp)
              * stab_param_
              * std::abs(temp) // should be 1 but use 0.5 for safety
              * (0.5 + 0.5*std::tanh( (temp-1)/kcPermeability(cell,qp)  ))
              / biotModulus(cell, qp)
              * ( wBF(cell, node, qp) );
          }
        }
      }
    }
  }