void ConnectivityGlobalPlugin::update(CC3DXMLElement *_xmlData, bool _fullInitFlag) {

	if (potts->getDisplayUnitsFlag()) {
		Unit energyUnit = potts->getEnergyUnit();




		CC3DXMLElement * unitsElem = _xmlData->getFirstElement("Units");
		if (!unitsElem) { //add Units element
			unitsElem = _xmlData->attachElement("Units");
		}

		if (unitsElem->getFirstElement("PenaltyUnit")) {
			unitsElem->getFirstElement("PenaltyUnit")->updateElementValue(energyUnit.toString());
		}
		else {
			CC3DXMLElement * energyElem = unitsElem->attachElement("PenaltyUnit", energyUnit.toString());
		}
	}

	penaltyVec.clear();

	Automaton *automaton = potts->getAutomaton();
	ASSERT_OR_THROW("CELL TYPE PLUGIN WAS NOT PROPERLY INITIALIZED YET. MAKE SURE THIS IS THE FIRST PLUGIN THAT YOU SET", automaton)
		set<unsigned char> cellTypesSet;


	map<unsigned char, double> typeIdConnectivityPenaltyMap;

	if (_xmlData->getFirstElement("DoNotPrecheckConnectivity")) {
		doNotPrecheckConnectivity = true;
	}

	if (_xmlData->getFirstElement("FastAlgorithm")) {
		fast_algorithm = true;
		changeEnergyFcnPtr = &ConnectivityGlobalPlugin::changeEnergyFast;
	}


	CC3DXMLElementList penaltyVecXML = _xmlData->getElements("Penalty");

	CC3DXMLElementList connectivityOnVecXML = _xmlData->getElements("ConnectivityOn");

	ASSERT_OR_THROW("You cannot use Penalty and ConnectivityOn tags together. Stick to one convention", !(connectivityOnVecXML.size() && penaltyVecXML.size()));

	// previous ASSERT_OR_THROW will encure that only one of the subsequent for loops be executed 

	for (int i = 0; i < penaltyVecXML.size(); ++i) {
		typeIdConnectivityPenaltyMap.insert(make_pair(automaton->getTypeId(penaltyVecXML[i]->getAttribute("Type")), penaltyVecXML[i]->getDouble()));


		//inserting all the types to the set (duplicate are automatically eleminated) to figure out max value of type Id
		cellTypesSet.insert(automaton->getTypeId(penaltyVecXML[i]->getAttribute("Type")));

	}



	for (int i = 0; i < connectivityOnVecXML.size(); ++i) {
		typeIdConnectivityPenaltyMap.insert(make_pair(automaton->getTypeId(connectivityOnVecXML[i]->getAttribute("Type")), 1.0));
		//inserting all the types to the set (duplicate are automatically eleminated) to figure out max value of type Id
		cellTypesSet.insert(automaton->getTypeId(connectivityOnVecXML[i]->getAttribute("Type")));

	}


	//Now that we know all the types used in the simulation we will find size of the penaltyVec
	vector<unsigned char> cellTypesVector(cellTypesSet.begin(), cellTypesSet.end());//coping set to the vector

	int size = 0;
	if (cellTypesVector.size()) {
		size = *max_element(cellTypesVector.begin(), cellTypesVector.end());
	}

	maxTypeId = size;

	size += 1;//if max element is e.g. 5 then size has to be 6 for an array to be properly allocated



	int index;
	penaltyVec.assign(size, 0.0);
	//inserting connectivity penalty values to penaltyVec;
	for (map<unsigned char, double>::iterator mitr = typeIdConnectivityPenaltyMap.begin(); mitr != typeIdConnectivityPenaltyMap.end(); ++mitr) {
		penaltyVec[mitr->first] = fabs(mitr->second);
	}

	cerr << "size=" << size << endl;
	for (int i = 0; i < size; ++i) {
		cerr << "penaltyVec[" << i << "]=" << penaltyVec[i] << endl;
	}

	//Here I initialize max neighbor index for direct acces to the list of neighbors 
	boundaryStrategy = BoundaryStrategy::getInstance();
	maxNeighborIndex = 0;


	maxNeighborIndex = boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(1);


	cerr << "ConnectivityGlobal maxNeighborIndex=" << maxNeighborIndex << endl;

	
	WatchableField3D<CellG *> *cellFieldG = (WatchableField3D<CellG *> *)potts->getCellFieldG();
	Dim3D fieldDim = cellFieldG->getDim();

	// max_neighbor_index_local_search is different depending whether we are on hex or cartesian lattice and if this is 2D or 3D simulation
	if (boundaryStrategy->getLatticeType() == HEXAGONAL_LATTICE) { // on hex lattice in 2D and 3D nearest neighbors "completely cover" a given pixel 
		max_neighbor_index_local_search = boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(1);
	}
	else {
		if (fieldDim.x == 1 || fieldDim.y == 1 || fieldDim.z == 1) { //2D simulation 
			max_neighbor_index_local_search = boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(2);
		}
		else { //3D
			max_neighbor_index_local_search = boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(3);
		}
	}

}
Exemplo n.º 2
0
void AdhesionFlexPlugin::update(CC3DXMLElement *_xmlData, bool _fullInitFlag){

	automaton = potts->getAutomaton();
	ASSERT_OR_THROW("CELL TYPE PLUGIN WAS NOT PROPERLY INITIALIZED YET. MAKE SURE THIS IS THE FIRST PLUGIN THAT YOU SET", automaton)
		set<unsigned char> cellTypesSet;


	//scanning Adhesion Molecule names

	CC3DXMLElementList adhesionMoleculeNameXMLVec=_xmlData->getElements("AdhesionMolecule");
	vector<string> adhesionMoleculeNameVec;
	set<string> adhesionMoleculeNameSet;
	moleculeNameIndexMap.clear();

	for (int i = 0 ; i<adhesionMoleculeNameXMLVec.size(); ++i){
		string moleculeName=adhesionMoleculeNameXMLVec[i]->getAttribute("Molecule");
		if (! adhesionMoleculeNameSet.insert(moleculeName).second){
			ASSERT_OR_THROW(string("Duplicate molecule Name=")+moleculeName+ " specified in AdhesionMolecule section ", false);
		}        
		adhesionMoleculeNameVec.push_back(moleculeName);
		moleculeNameIndexMap.insert(make_pair(moleculeName,i));
	}

	numberOfAdhesionMolecules=moleculeNameIndexMap.size();
	if (!sim->getRestartEnabled()){	
		adhesionMoleculeDensityVecMedium=vector<float>(numberOfAdhesionMolecules,0.0);
	}
	cerr<<"numberOfAdhesionMolecules="<<numberOfAdhesionMolecules<<endl;

	//scannning AdhesionMoleculeDensity section

	CC3DXMLElementList adhesionMoleculeDensityXMLVec=_xmlData->getElements("AdhesionMoleculeDensity");    
	typeToAdhesionMoleculeDensityMap.clear();
	std::map<int,std::vector<float> >::iterator mitr;

	for (int i = 0 ; i<adhesionMoleculeDensityXMLVec.size(); ++i){
		int typeId=automaton->getTypeId(adhesionMoleculeDensityXMLVec[i]->getAttribute("CellType"));

		cerr<<"typeId="<<typeId<<endl;


		mitr=typeToAdhesionMoleculeDensityMap.find(typeId);
		if (mitr==typeToAdhesionMoleculeDensityMap.end()){
			typeToAdhesionMoleculeDensityMap.insert(make_pair(typeId,vector<float>(numberOfAdhesionMolecules,0.0)));
			cerr<<"typeToAdhesionMoleculeDensityMap[typeId].size()="<<typeToAdhesionMoleculeDensityMap[typeId].size()<<endl;
		}


		string moleculeName=adhesionMoleculeDensityXMLVec[i]->getAttribute("Molecule");
		cerr<<"moleculeName="<<moleculeName<<endl;
		if(moleculeNameIndexMap.find(moleculeName)==moleculeNameIndexMap.end()){
			ASSERT_OR_THROW(string("Molecule Name=")+moleculeName+" was not declared in the AdhesionMolecule section",false);
		}
		cerr<<"moleculeNameIndexMap[moleculeName]="<<moleculeNameIndexMap[moleculeName]<<endl;
		cerr<<"adhesionMoleculeDensityXMLVec[i]->getAttributeAsDouble(Density)="<<adhesionMoleculeDensityXMLVec[i]->getAttributeAsDouble("Density")<<endl;
		cerr<<"typeToAdhesionMoleculeDensityMap[typeId].size()="<<typeToAdhesionMoleculeDensityMap[typeId].size()<<endl;
		typeToAdhesionMoleculeDensityMap[typeId][moleculeNameIndexMap[moleculeName]]=adhesionMoleculeDensityXMLVec[i]->getAttributeAsDouble("Density");
		cerr<<"AFTER ASSIGNING DENSITY"<<endl;
	}


	//scanning BindingFormula section

	CC3DXMLElement * bindingFormulaXMLElem=_xmlData->getFirstElement("BindingFormula");

	formulaString=bindingFormulaXMLElem->getFirstElement("Formula")->getText(); //formula string

	CC3DXMLElement * variablesSectionXMLElem=bindingFormulaXMLElem->getFirstElement("Variables");
	//cerr<<"formulaString="<<formulaString<<endl;


	//here we can add options depending on variables input - for now it is har-coded to accept only matrix of bindingParameters
	bindingParameters.clear() ; //have to clear binding parameters
	CC3DXMLElement * adhesionInteractionMatrixXMLElem = variablesSectionXMLElem->getFirstElement("AdhesionInteractionMatrix");
	CC3DXMLElementList bindingParameterXMLVec = adhesionInteractionMatrixXMLElem->getElements("BindingParameter");
	for (int i = 0 ; i<bindingParameterXMLVec.size(); ++i){		
		setBindingParameter(bindingParameterXMLVec[i]->getAttribute("Molecule1") , bindingParameterXMLVec[i]->getAttribute("Molecule2"), bindingParameterXMLVec[i]->getDouble());
	}


    //vectorized variables for convenient parallel access 
   unsigned int maxNumberOfWorkNodes=pUtils->getMaxNumberOfWorkNodesPotts();
   molecule1Vec.assign(maxNumberOfWorkNodes,0.0);
   molecule2Vec.assign(maxNumberOfWorkNodes,0.0);
   pVec.assign(maxNumberOfWorkNodes,mu::Parser());    

   for (int i  = 0 ; i< maxNumberOfWorkNodes ; ++i){
    pVec[i].DefineVar("Molecule1",&molecule1Vec[i]);
    pVec[i].DefineVar("Molecule2",&molecule2Vec[i]);
    pVec[i].SetExpr(formulaString);
   }

	// p=mu::Parser(); //using new parser
	// //setting up muParser
	// p.DefineVar("Molecule1", &molecule1);
	// p.DefineVar("Molecule2", &molecule2);	
	// p.SetExpr(formulaString);





	//scanning NeighborOrder or Depth
	//Here I initialize max neighbor index for direct acces to the list of neighbors 
	boundaryStrategy=BoundaryStrategy::getInstance();
	maxNeighborIndex=0;

	if(_xmlData->getFirstElement("Depth")){
		maxNeighborIndex=boundaryStrategy->getMaxNeighborIndexFromDepth(_xmlData->getFirstElement("Depth")->getDouble());
		//cerr<<"got here will do depth"<<endl;
	}else{
		//cerr<<"got here will do neighbor order"<<endl;
		if(_xmlData->getFirstElement("NeighborOrder")){

			maxNeighborIndex=boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(_xmlData->getFirstElement("NeighborOrder")->getUInt());	
			cerr<<"maxNeighborIndex="<<maxNeighborIndex<<endl;
		}else{
			maxNeighborIndex=boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(1);

		}

	}


	cerr<<"sizeBindingArray="<<moleculeNameIndexMap.size()<<endl;
	//initializing binding parameter array
	int sizeBindingArray=moleculeNameIndexMap.size();

	int indexBindingArray ;
	bindingParameterArray.clear();
	bindingParameterArray.assign(sizeBindingArray,vector<double>(sizeBindingArray,0.0));
	bindingParameters_t::iterator bmitr;
	
	for(int i = 0 ; i < sizeBindingArray ; ++i)
		for(int j = 0 ; j < sizeBindingArray ; ++j){

			indexBindingArray= getIndex(i,j);

			bmitr=bindingParameters.find(indexBindingArray);

			if(bmitr!=bindingParameters.end()){
				bindingParameterArray[i][j] = bmitr->second;
			}


		}

		for(int i = 0 ; i < sizeBindingArray ; ++i)
			for(int j = 0 ; j < sizeBindingArray ; ++j){

				cerr<<"bindingParameterArray["<<i<<"]["<<j<<"]="<<bindingParameterArray[i][j]<<endl;

			}    

			


}
void BoundaryPixelTrackerPlugin::update(CC3DXMLElement *_xmlData, bool _fullInitFlag) {


	//Here I initialize max neighbor index for direct acces to the list of neighbors 
	boundaryStrategy = BoundaryStrategy::getInstance();
	maxNeighborIndex = 0;

	if (!_xmlData) { //this happens if plugin is loaded directly as a dependency from another plugin
		maxNeighborIndex = boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(1);
		return;
	}



	if (_xmlData->getFirstElement("Depth")) {
		maxNeighborIndex = boundaryStrategy->getMaxNeighborIndexFromDepth(_xmlData->getFirstElement("Depth")->getDouble());



		// when user specifies depth , fetching of boundary for neighbor order might not work properly - not a big deal because almost nobody is using the Depth tag
		neighborOrder = 0;

		//cerr<<"got here will do depth"<<endl;
	}
	else {
		//cerr<<"got here will do neighbor order"<<endl;
		if (_xmlData->getFirstElement("NeighborOrder")) {

			neighborOrder = _xmlData->getFirstElement("NeighborOrder")->getUInt();
			maxNeighborIndex = boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(neighborOrder);


		}
		else {
			neighborOrder = 1;
			maxNeighborIndex = boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(1);
		}



		std::set<int>  extraBoundariesNeighborOrderSet;
		CC3DXMLElementList extraBoundariesVec = _xmlData->getElements("ExtraBoundary");

		for (int i = 0; i < extraBoundariesVec.size(); ++i) {
			extraBoundariesNeighborOrderSet.insert(extraBoundariesVec[i]->getAttributeAsInt("NeighborOrder"));

		}

		extraBoundariesNeighborOrder.assign(extraBoundariesNeighborOrderSet.begin(), extraBoundariesNeighborOrderSet.end());
		extraBoundariesMaxNeighborIndex.assign(extraBoundariesNeighborOrder.size(), 0); //allocating memory in the extraBoundariesMaxNeighborIndex vector

		
		for (unsigned int i = 0; i < extraBoundariesNeighborOrder.size(); ++i) {
			extraBoundariesMaxNeighborIndex[i] = boundaryStrategy->getMaxNeighborIndexFromNeighborOrder(extraBoundariesNeighborOrder[i]);
		}

		for (unsigned int i = 0; i < extraBoundariesMaxNeighborIndex.size(); ++i) {
			cerr << "i=" << i << " extraBoundariesMaxNeighborIndex[i]=" << extraBoundariesMaxNeighborIndex[i] << endl;
		}

	}
}
Exemplo n.º 4
0
int main(int argc, char* argv[])
{
    cerr << "Welcome to CC3D command line edition" << endl;

    // If we'd want to redirect cerr & cerr to a file (also see at end)
    //  std::ofstream logFile("cc3d-out.txt");
    //  std::streambuf *outbuf = std::cerr.rdbuf(logFile.rdbuf());
    //  std::streambuf *errbuf = std::cerr.rdbuf(logFile.rdbuf());

    try {
        // Command line
        if (argc < 2)
            Syntax(argv[0]);

        // Load Plugin Libaries
        // Libaries in COMPUCELL3D_PLUGIN_PATH can override the
        // DEFAULT_PLUGIN_PATH
        char* steppablePath = getenv("COMPUCELL3D_STEPPABLE_PATH");
        cerr << "steppablePath=" << steppablePath << endl;
        if (steppablePath)
            Simulator::steppableManager.loadLibraries(steppablePath);

        char* pluginPath = getenv("COMPUCELL3D_PLUGIN_PATH");
        cerr << "pluginPath=" << pluginPath << endl;
        if (pluginPath)
            Simulator::pluginManager.loadLibraries(pluginPath);

#ifdef DEFAULT_PLUGIN_PATH
        Simulator::steppableManager.loadLibraries(DEFAULT_PLUGIN_PATH);
//     Simulator::pluginManager.loadLibraries(DEFAULT_PLUGIN_PATH);
#endif

        BasicPluginManager<Steppable>::infos_t* infosG = &Simulator::steppableManager.getPluginInfos();

        if (!infosG->empty()) {
            cerr << "Found the following Steppables:" << endl;
            BasicPluginManager<Steppable>::infos_t::iterator it;
            for (it = infosG->begin(); it != infosG->end(); it++)
                cerr << "  " << *(*it) << endl;
            cerr << endl;
        }

        BasicPluginManager<Plugin>::infos_t* infos = &Simulator::pluginManager.getPluginInfos();

        if (!infos->empty()) {
            cerr << "Found the following plugins:" << endl;
            BasicPluginManager<Plugin>::infos_t::iterator it;
            for (it = infos->begin(); it != infos->end(); it++)
                cerr << "  " << *(*it) << endl;
            cerr << endl;
        }
    }
    catch (const BasicException& e) {
        cerr << "ERROR: " << e << endl;
    }

    XMLParserExpat xmlParser;
    if (argc < 2) {
        cerr << "SPECIFY XML FILE" << endl;
        exit(0);
    }
    xmlParser.setFileName(string(argv[1]));
    xmlParser.parse();

    // Create Simulator
    Simulator sim;

    //extracting plugin elements from the XML file
    CC3DXMLElementList pluginDataList = xmlParser.rootElement->getElements("Plugin");
    for (int i = 0; i < pluginDataList.size(); ++i) {
        cerr << "Plugin: " << pluginDataList[i]->getAttribute("Name") << endl;
        sim.ps.addPluginDataCC3D(pluginDataList[i]);
    }

    //extracting steppable elements from the XML file
    CC3DXMLElementList steppableDataList = xmlParser.rootElement->getElements("Steppable");
    for (int i = 0; i < steppableDataList.size(); ++i) {
        cerr << "Steppable: " << steppableDataList[i]->getAttribute("Type") << endl;
        sim.ps.addSteppableDataCC3D(steppableDataList[i]);
    }

    // extracting Potts section
    CC3DXMLElementList pottsDataList = xmlParser.rootElement->getElements("Potts");
    ASSERT_OR_THROW("You must have exactly 1 definition of the Potts section", pottsDataList.size() == 1);
    sim.ps.addPottsDataCC3D(pottsDataList[0]);

    //    extracting Metadata section
    CC3DXMLElementList metadataDataList = xmlParser.rootElement->getElements("Metadata");
    if (metadataDataList.size() == 1) {
        sim.ps.addMetadataDataCC3D(metadataDataList[0]);
    }
    else {
        cerr << "Not using Metadata" << endl;
    }
    //     ASSERT_OR_THROW("You must have exactly 1 definition of the Metadata section",metadataDataList.size()==1);

    sim.initializeCC3D();

    sim.extraInit(); ///additional initialization after all plugins and steppables have been loaded and preinitialized
// Run simulation

#if defined(_WIN32)
    volatile DWORD dwStart;
    dwStart = GetTickCount();
#endif

    sim.start();

    for (unsigned int i = 1; i <= sim.getNumSteps(); i++) {
        sim.step(i);
    }
    sim.finish();

#if defined(_WIN32)
    cerr << "SIMULATION TOOK " << GetTickCount() - dwStart << " miliseconds to complete" << endl;
    dwStart = GetTickCount();
#endif

    return 0;
}
Exemplo n.º 5
0
void FiPySolver::update(CC3DXMLElement *_xmlData, bool _fullInitFlag){
	
	//notice, only basic steering is enabled for PDE solvers - changing diffusion constants, do -not-diffuse to types etc...
	// Coupling coefficients cannot be changed and also there is no way to allocate extra fields while simulation is running

	if(potts->getDisplayUnitsFlag()){
		Unit diffConstUnit=powerUnit(potts->getLengthUnit(),2)/potts->getTimeUnit();
		Unit decayConstUnit=1/potts->getTimeUnit();
		Unit secretionConstUnit=1/potts->getTimeUnit();

		CC3DXMLElement * unitsElem=_xmlData->getFirstElement("Units"); 
		if (!unitsElem){ //add Units element
			unitsElem=_xmlData->attachElement("Units");
		}

		if(unitsElem->getFirstElement("DiffusionConstantUnit")){
			unitsElem->getFirstElement("DiffusionConstantUnit")->updateElementValue(diffConstUnit.toString());
		}else{
			unitsElem->attachElement("DiffusionConstantUnit",diffConstUnit.toString());
		}

		if(unitsElem->getFirstElement("DecayConstantUnit")){
			unitsElem->getFirstElement("DecayConstantUnit")->updateElementValue(decayConstUnit.toString());
		}else{
			unitsElem->attachElement("DecayConstantUnit",decayConstUnit.toString());
		}

		if(unitsElem->getFirstElement("DeltaXUnit")){
			unitsElem->getFirstElement("DeltaXUnit")->updateElementValue(potts->getLengthUnit().toString());
		}else{
			unitsElem->attachElement("DeltaXUnit",potts->getLengthUnit().toString());
		}

		if(unitsElem->getFirstElement("DeltaTUnit")){
			unitsElem->getFirstElement("DeltaTUnit")->updateElementValue(potts->getTimeUnit().toString());
		}else{
			unitsElem->attachElement("DeltaTUnit",potts->getTimeUnit().toString());
		}

		if(unitsElem->getFirstElement("CouplingCoefficientUnit")){
			unitsElem->getFirstElement("CouplingCoefficientUnit")->updateElementValue(decayConstUnit.toString());
		}else{
			unitsElem->attachElement("CouplingCoefficientUnit",decayConstUnit.toString());
		}



		if(unitsElem->getFirstElement("SecretionUnit")){
			unitsElem->getFirstElement("SecretionUnit")->updateElementValue(secretionConstUnit.toString());
		}else{
			unitsElem->attachElement("SecretionUnit",secretionConstUnit.toString());
		}

		if(unitsElem->getFirstElement("SecretionOnContactUnit")){
			unitsElem->getFirstElement("SecretionOnContactUnit")->updateElementValue(secretionConstUnit.toString());
		}else{
			unitsElem->attachElement("SecretionOnContactUnit",secretionConstUnit.toString());
		}

		if(unitsElem->getFirstElement("ConstantConcentrationUnit")){
			unitsElem->getFirstElement("ConstantConcentrationUnit")->updateElementValue(secretionConstUnit.toString());
		}else{
			unitsElem->attachElement("ConstantConcentrationUnit",secretionConstUnit.toString());
		}

		if(unitsElem->getFirstElement("DecayConstantUnit")){
			unitsElem->getFirstElement("DecayConstantUnit")->updateElementValue(decayConstUnit.toString());
		}else{
			unitsElem->attachElement("DecayConstantUnit",decayConstUnit.toString());
		}

		if(unitsElem->getFirstElement("DeltaXUnit")){
			unitsElem->getFirstElement("DeltaXUnit")->updateElementValue(potts->getLengthUnit().toString());
		}else{
			unitsElem->attachElement("DeltaXUnit",potts->getLengthUnit().toString());
		}

		if(unitsElem->getFirstElement("DeltaTUnit")){
			unitsElem->getFirstElement("DeltaTUnit")->updateElementValue(potts->getTimeUnit().toString());
		}else{
			unitsElem->attachElement("DeltaTUnit",potts->getTimeUnit().toString());
		}

		if(unitsElem->getFirstElement("CouplingCoefficientUnit")){
			unitsElem->getFirstElement("CouplingCoefficientUnit")->updateElementValue(decayConstUnit.toString());
		}else{
			unitsElem->attachElement("CouplingCoefficientUnit",decayConstUnit.toString());
		}

		if(unitsElem->getFirstElement("UptakeUnit")){
			unitsElem->getFirstElement("UptakeUnit")->updateElementValue(decayConstUnit.toString());
		}else{
			unitsElem->attachElement("UptakeUnit",decayConstUnit.toString());
		}

		if(unitsElem->getFirstElement("RelativeUptakeUnit")){
			unitsElem->getFirstElement("RelativeUptakeUnit")->updateElementValue(decayConstUnit.toString());
		}else{
			unitsElem->attachElement("RelativeUptakeUnit",decayConstUnit.toString());
		}

		if(unitsElem->getFirstElement("MaxUptakeUnit")){
			unitsElem->getFirstElement("MaxUptakeUnit")->updateElementValue(decayConstUnit.toString());
		}else{
			unitsElem->attachElement("MaxUptakeUnit",decayConstUnit.toString());
		}



	}


	diffSecrFieldTuppleVec.clear();
	bcSpecVec.clear();
	bcSpecFlagVec.clear();

	CC3DXMLElementList diffFieldXMLVec=_xmlData->getElements("DiffusionField");
	for(unsigned int i = 0 ; i < diffFieldXMLVec.size() ; ++i ){
		diffSecrFieldTuppleVec.push_back(DiffusionSecretionFiPyFieldTupple());
		DiffusionData & diffData=diffSecrFieldTuppleVec[diffSecrFieldTuppleVec.size()-1].diffData;
		SecretionData & secrData=diffSecrFieldTuppleVec[diffSecrFieldTuppleVec.size()-1].secrData;

		if(diffFieldXMLVec[i]->findElement("DiffusionData"))
			diffData.update(diffFieldXMLVec[i]->getFirstElement("DiffusionData"));

		if(diffFieldXMLVec[i]->findElement("SecretionData"))
			secrData.update(diffFieldXMLVec[i]->getFirstElement("SecretionData"));

		if(diffFieldXMLVec[i]->findElement("ReadFromFile"))
			readFromFileFlag=true;

		//boundary conditions parsing
		bcSpecFlagVec.push_back(false);
		bcSpecVec.push_back(BoundaryConditionSpecifier());

		if (diffFieldXMLVec[i]->findElement("BoundaryConditions")){
			bcSpecFlagVec[bcSpecFlagVec.size()-1]=true;
			BoundaryConditionSpecifier & bcSpec = bcSpecVec[bcSpecVec.size()-1];

			CC3DXMLElement * bcSpecElem = diffFieldXMLVec[i]->getFirstElement("BoundaryConditions");
			CC3DXMLElementList planeVec = bcSpecElem->getElements("Plane");



			for(unsigned int ip = 0 ; ip < planeVec.size() ; ++ip ){
				ASSERT_OR_THROW ("Boundary Condition specification Plane element is missing Axis attribute",planeVec[ip]->findAttribute("Axis"));
				string axisName=planeVec[ip]->getAttribute("Axis");
				int index=0;
				if (axisName=="x" ||axisName=="X" ){
					index=0;
				}
				if (axisName=="y" ||axisName=="Y" ){
					index=2;
				}
				if (axisName=="z" ||axisName=="Z" ){
					index=4;
				}

				if (planeVec[ip]->findElement("Periodic")){
					bcSpec.planePositions[index]=BoundaryConditionSpecifier::PERIODIC;
					bcSpec.planePositions[index+1]=BoundaryConditionSpecifier::PERIODIC;
				}else {
					//if (planeVec[ip]->findElement("ConstantValue")){
					CC3DXMLElementList cvVec=planeVec[ip]->getElements("ConstantValue");
					CC3DXMLElementList cdVec=planeVec[ip]->getElements("ConstantDerivative");

					for (unsigned int v = 0 ; v < cvVec.size() ; ++v ){
						string planePos=cvVec[v]->getAttribute("PlanePosition");
						double value=cvVec[v]->getAttributeAsDouble("Value");
						changeToLower(planePos);
						if (planePos=="min"){
							bcSpec.planePositions[index]=BoundaryConditionSpecifier::CONSTANT_VALUE;
							bcSpec.values[index]=value;

						}else if (planePos=="max"){
							bcSpec.planePositions[index+1]=BoundaryConditionSpecifier::CONSTANT_VALUE;
							bcSpec.values[index+1]=value;
						}else{
							ASSERT_OR_THROW("PlanePosition attribute has to be either max on min",false);
						}

					}
					if (cvVec.size()<=1){
						for (unsigned int d = 0 ; d < cdVec.size() ; ++d ){
							string planePos=cdVec[d]->getAttribute("PlanePosition");
							double value=cdVec[d]->getAttributeAsDouble("Value");
							changeToLower(planePos);
							if (planePos=="min"){
								bcSpec.planePositions[index]=BoundaryConditionSpecifier::CONSTANT_DERIVATIVE;
								bcSpec.values[index]=value;

							}else if (planePos=="max"){
								bcSpec.planePositions[index+1]=BoundaryConditionSpecifier::CONSTANT_DERIVATIVE;
								bcSpec.values[index+1]=value;
							}else{
								ASSERT_OR_THROW("PlanePosition attribute has to be either max on min",false);
							}

						}
					}

				}

			}

		}
	}
	if(_xmlData->findElement("Serialize")){
		serializeFlag=true;
		if(_xmlData->getFirstElement("Serialize")->findAttribute("Frequency")){
			serializeFrequency=_xmlData->getFirstElement("Serialize")->getAttributeAsUInt("Frequency");
		}
		cerr<<"serialize Flag="<<serializeFlag<<endl;
	}

	if(_xmlData->findElement("ReadFromFile")){
		readFromFileFlag=true;
		cerr<<"readFromFileFlag="<<readFromFileFlag<<endl;
	}

	for(int i = 0 ; i < diffSecrFieldTuppleVec.size() ; ++i){
		diffSecrFieldTuppleVec[i].diffData.setAutomaton(automaton);
		diffSecrFieldTuppleVec[i].secrData.setAutomaton(automaton);
		diffSecrFieldTuppleVec[i].diffData.initialize(automaton);
		diffSecrFieldTuppleVec[i].secrData.initialize(automaton);
	}

	///assigning member method ptrs to the vector
	for(unsigned int i = 0 ; i < diffSecrFieldTuppleVec.size() ; ++i){

		diffSecrFieldTuppleVec[i].secrData.secretionFcnPtrVec.assign(diffSecrFieldTuppleVec[i].secrData.secrTypesNameSet.size(),0);
		unsigned int j=0;
		for(set<string>::iterator sitr=diffSecrFieldTuppleVec[i].secrData.secrTypesNameSet.begin() ; sitr != diffSecrFieldTuppleVec[i].secrData.secrTypesNameSet.end()  ; ++sitr){

			if((*sitr)=="Secretion"){
				diffSecrFieldTuppleVec[i].secrData.secretionFcnPtrVec[j]=&FiPySolver::secreteSingleField;
				++j;
			}
			else if((*sitr)=="SecretionOnContact"){
				diffSecrFieldTuppleVec[i].secrData.secretionFcnPtrVec[j]=&FiPySolver::secreteOnContactSingleField;
				++j;
			}
			else if((*sitr)=="ConstantConcentration"){
				diffSecrFieldTuppleVec[i].secrData.secretionFcnPtrVec[j]=&FiPySolver::secreteConstantConcentrationSingleField;
				++j;
			}
		}
	}
}