Magnetostatic Application Application Files

From KratosWiki
Revision as of 11:45, 2 February 2010 by JMora (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Creation of our Magnetostatic Kratos application files

The following files (above in bold characters) are those that you will have to create, that we will review later.

  • kMagnetostatic.h
  • kMagnetostatic.cpp
  • Jamfile
  • kMagnetostatic_python_application.cpp
  • static_poisson_solver.py

In addition, you have to indicate to the Kratos Kernel that you have created a new application, in order to be included in the whole Kratos. To do this, you will have also to modify the following files:

  • in the main applications' directory (/kratos/applications/applications_interface.py);
  • in the Kratos root (/kratos/Jamroot);

Creation of our Application files

In summary, we have to create (or modify if you are using other application files:

  • /kratos/applications/kMagnetostatic/kMagnetostatic.h
  • /kratos/applications/kMagnetostatic/kMagnetostatic.cpp
  • /kratos/applications/kMagnetostatic/Jamfile
  • /kratos/applications/kMagnetostatic/custom_python/kMagnetostatic_python_application.cpp
  • /kratos/applications/kMagnetostatic/python_scripts/static_poisson_solver.py
  • /kratos/applications/applications_interface.py
  • /kratos/Jamroot


Let's go to create these files (note that we have three C++ files and three python files):

Header application file: kMagnetostatic.h

The first lines (comments) indicate the author's name (your name), date and hour of the last revision, and revision number, as usual in other codes.

//   
//   Project Name:        Kratos       
//   Last Modified by:    $Author: jmora $ rrossi $
//   Date:                $Date: 2010-02-02 $
//   Revision:            $Revision: 1.4 $
//
//

In order to avoid class redefinition, you have to define a label for your application definition, as follows:

#if !defined(KRATOS_MAGNETOSTATIC_H_INCLUDED )
#define  KRATOS_MAGNETOSTATIC_H_INCLUDED

the #endif is at the end of the code (the rest of the lines must be included between these ones):

#endif // KRATOS_MAGNETOSTATIC_H_INCLUDED  defined

Now you have to add the "include" files (note that here you define the element to be used, magnetostatic_2d.h, for the rest of include files you can copy as it is):

// System includes
#include <string>
#include <iostream>  


// External includes 

// Project includes
#include "includes/define.h"
#include "includes/kratos_application.h"

#include "custom_elements/magnetostatic_2d.h"
#include "custom_conditions/pointcurrent2D.h"
#include "custom_conditions/mfield2D.h"

#include "includes/variables.h"
#include "includes/condition.h"
#include "includes/ublas_interface.h"

Declare the namespace Kratos:

namespace Kratos
{

 	///@name Kratos Globals
 	///@{ 

 	// Variables definition 

	///@} 
	///@name Type Definitions
	///@{ 

	///@} 
	///@name  Enum's
	///@{

	///@}
	///@name  Functions 
	///@{

	///@}
	///@name Kratos Classes
	///@{

	/// Short class definition.
	/** Detail class definition.
	*/

Now, coming from the element definition, remember that we have called our application KratosR1MagnetostaticApplication, the name we have to use in the following lines:

	class KratosR1MagnetostaticApplication : public KratosApplication
	{
	public:
		///@name Type Definitions
		///@{
		
		/// Pointer definition of KratosR1MagnetostaticApplication
		KRATOS_CLASS_POINTER_DEFINITION(KratosR1MagnetostaticApplication);

		///@}
		///@name Life Cycle 
		///@{ 

		/// Default constructor.
		KratosR1MagnetostaticApplication();

		/// Destructor.
		virtual ~KratosR1MagnetostaticApplication(){}

		///@}
		///@name Operators 
		///@{

		///@}
		///@name Operations
		///@{

		virtual void Register();

		///@}
		///@name Access
		///@{ 

		///@}
		///@name Inquiry
		///@{

		///@}      
		///@name Input and output
		///@{

		/// Turn back information as a string.
		virtual std::string Info() const
		{
			return "KratosR1MagnetostaticApplication";
		}

		/// Print information about this object.
		virtual void PrintInfo(std::ostream& rOStream) const
		{
			rOStream << Info();
			PrintData(rOStream);
		}

		///// Print object's data.
      virtual void PrintData(std::ostream& rOStream) const
      {
     	KRATOS_WATCH("in KratosR1MagnetostaticApplication");
     	KRATOS_WATCH(KratosComponents<VariableData>::GetComponents().size() );
		rOStream << "Variables:" << std::endl;
		KratosComponents<VariableData>().PrintData(rOStream);
		rOStream << std::endl;
		rOStream << "Elements:" << std::endl;
		KratosComponents<Element>().PrintData(rOStream);
		rOStream << std::endl;
		rOStream << "Conditions:" << std::endl;
		KratosComponents<Condition>().PrintData(rOStream);
     }
 
		///@}      
		///@name Friends
 		///@{

  		///@}

	protected:
		///@name Protected static Member Variables 
		///@{ 


 		///@} 
		///@name Protected member Variables 
		///@{ 
 

		///@} 
		///@name Protected Operators
		///@{ 

 		///@} 
		///@name Protected Operations
		///@{ 

		///@} 
		///@name Protected  Access 
		///@{ 

 		///@}      
		///@name Protected Inquiry 
		///@{ 

		///@}    
		///@name Protected LifeCycle 
		///@{ 

		///@}

Now we have to declare our element class name (Magnetostatic2D), and the conditions (PointCurrent2D, Mfield2D):

	private:
		///@name Static Member Variables 
		///@{ 

		//       static const ApplicationCondition  msApplicationCondition; 

		///@} 
		///@name Member Variables 
		///@{ 
		const Magnetostatic2D mMagnetostatic2D;
		const PointCurrent2D  mPointCurrent2D;
		const Mfield2D  mMfield2D;

		///@} 
		///@name Private Operators
		///@{ 

		///@} 
		///@name Private Operations
		///@{ 

		///@} 
		///@name Private  Access 
		///@{ 

		///@}    
		///@name Private Inquiry 
		///@{ 

		///@}    
		///@name Un accessible methods 
		///@{

And, finally, we have to declare the assignment operator and constructor method (remember to close the namespace definition and #endif label if you had not done it before):

		/// Assignment operator.
		KratosR1MagnetostaticApplication& operator=(KratosR1MagnetostaticApplication const& rOther);

		/// Copy constructor.
		KratosR1MagnetostaticApplication(KratosR1MagnetostaticApplication const& rOther);


		///@}    

	}; // Class KratosR1MagnetostaticApplication 

	///@} 


	///@name Type Definitions       
	///@{ 


	///@} 
	///@name Input and output 
	///@{ 

	///@} 


}  // namespace Kratos.


#endif // KRATOS_MAGNETOSTATIC_H_INCLUDED  defined

Implementation application file: kMagnetostatic.cpp

The implementation file really doesn't need any comment. Just note that your customising parts are remarked in bold characters:

//   
//   
//   Project Name:        Kratos       
//   Last modified by:    $Author: rrossi  jmora $
//   Date:                $Date: 2010-02-02 $
//   Revision:            $Revision: 1.4 $
// 

// System includes

// External includes 

// Project includes
#include "includes/define.h"
#include "geometries/triangle_2d_3.h"
#include "geometries/triangle_3d_3.h"
#include "geometries/tetrahedra_3d_4.h"
#include "geometries/line_2d.h"
#include "kMagnetostatic.h"
#include "includes/variables.h"

namespace Kratos
{
	KratosR1MagnetostaticApplication::KratosR1MagnetostaticApplication():
		mMagnetostatic2D(0, Element::GeometryType::Pointer(new Triangle2D3<Node<3> >(Element::GeometryType::PointsArrayType(3, Node<3>())))),
       mPointCurrent2D(0, Element::GeometryType::Pointer(new Geometry <Node<3> >(Element::GeometryType::PointsArrayType(1, Node<3>())))),
		mMfield2D(0, Element::GeometryType::Pointer(new Line2D2<Node<3> >(Element::GeometryType::PointsArrayType(2, Node<3>()))))
	{}

 		
 	void KratosR1MagnetostaticApplication::Register()
	{
		// calling base class register to register Kratos components
		KratosApplication::Register();
		std::cout << "Initializing KratosR1MagnetostaticApplication... " << std::endl;

		// Registering elements and conditions here
		KRATOS_REGISTER_ELEMENT("Magnetostatic2D", mMagnetostatic2D);
		KRATOS_REGISTER_CONDITION("PointCurrent2D", mPointCurrent2D);
		KRATOS_REGISTER_CONDITION("Mfield2D", mMfield2D);


	}
	
}  // namespace Kratos.

Customising the python compiling application file: Jamfile

This file indicates Kratos where to find all the specific application files, therefore basically you should include your custom directories and files (note again that you have just to pay attention to the bold characters). Take care while modifying this file because python is highly sensitive to spaces and tab characters.

project MagnetostaticApplication
    : 
    source-location
       .
       custom_conditions
       custom_elements
       custom_python
       custom_utilities
       external_includes
    :
    requirements <include>. 
		<define>KRATOS_PYTHON
		<link>shared
    ;

#################################################################################
#################################################################################
##definition of "dependencies for the project"
# no libs needed for this application ... have a look to PFEMapplication for examples
# of use in a more general case

#################################################################################
#################################################################################
## list of files to be build, including dependencies to other libraries
import python ;
python-extension KratosR1MagnetostaticApplication
    :  
	#list of sources
	kMagnetostatic.cpp
	kMagnetostatic_python_application.cpp
	magnetostatic_2d.cpp
	pointcurrent2D.cpp
	mfield2D.cpp

	#kratos library
        ##/kratos-prj/kratos//libkratos/<link>static
    /KratosProject//libkratos_static
    	 
	#"system" includes	
	/KratosProject//pythonlib
	/KratosProject//boost_python_lib
    ;

#################################################################################
#################################################################################
## rules to install ... and to remove the prefix "lib"

install install : KratosR1MagnetostaticApplication : <location>$(TOP)/libs ;

Customising the python variables file: kMagnetostatic_python_application.cpp

The following file basically indicates Kratos the variables to be used by the pyhton commands. Therefore, we have just to modify the name of the application (KratosR1MagnetostaticApplication) and to add the variables names (MAGNETOSTATIC_POTENTIAL for the unknown, MAGNETIC_PERMEABILITY for the material property, MAGNETIC_FLUX_DENSITY and MAGNETIC_FIELD_INTENSITY for the gradient of the unknown, INFINIT_COEFFICIENT for the infinit boundary condition, MAGNETOSTATIC_SURFACE_CURRENT and MAGNETOSTATIC_POINT_CURRENT for the source terms).

Legal issues

/*
==============================================================================
KratosR1MagnetostaticApplication 
A library based on:
Kratos
A General Purpose Software for Multi-Physics Finite Element Analysis
Version 1.0 (Released on march 05, 2007).

Copyright 2010
Pooyan Dadvand, Riccardo Rossi, Javier Mora
pooyan@cimne.upc.edu 
rrossi@cimne.upc.edu
mora@cimne.upc.edu
- CIMNE (International Center for Numerical Methods in Engineering),
Gran Capita' s/n, 08034 Barcelona, Spain

Permission is hereby granted, free  of charge, to any person obtaining
a  copy  of this  software  and  associated  documentation files  (the
"Software"), to  deal in  the Software without  restriction, including
without limitation  the rights to  use, copy, modify,  merge, publish,
distribute,  sublicense and/or  sell copies  of the  Software,  and to
permit persons to whom the Software  is furnished to do so, subject to
the following condition:

Distribution of this code for  any  commercial purpose  is permissible
ONLY BY DIRECT ARRANGEMENT WITH THE COPYRIGHT OWNERS.

The  above  copyright  notice  and  this permission  notice  shall  be
included in all copies or substantial portions of the Software.

THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT  SHALL THE AUTHORS OR COPYRIGHT HOLDERS  BE LIABLE FOR ANY
CLAIM, DAMAGES OR  OTHER LIABILITY, WHETHER IN AN  ACTION OF CONTRACT,
TORT  OR OTHERWISE, ARISING  FROM, OUT  OF OR  IN CONNECTION  WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

==============================================================================
*/
//   
//   Project Name:        Kratos       
//   Last modified by:    $Author: jmora $
//   Date:                $Date: 2010-02-02 12:30:38 $
//   Revision:            $Revision: 1.0 $
//
//
// System includes 

#if defined(KRATOS_PYTHON)
// External includes 
#include <boost/python.hpp>


// Project includes 
#include "includes/define.h"
#include "kMagnetostatic.h"
  
namespace Kratos
{

namespace Python
{

  using namespace boost::python;


  
  BOOST_PYTHON_MODULE(KratosR1MagnetostaticApplication)
  {

	  class_<KratosR1MagnetostaticApplication, 
			  KratosR1MagnetostaticApplication::Pointer, 
			  bases<KratosApplication>, boost::noncopyable >("KratosR1MagnetostaticApplication")
			;

		//registering variables in python
		// for electromagnetic applications
		// for kMagnetostatic application
		KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(MAGNETIC_PERMEABILITY)
		KRATOS_REGISTER_IN_PYTHON_VARIABLE(MAGNETOSTATIC_POTENTIAL)
		KRATOS_REGISTER_IN_PYTHON_VARIABLE(MAGNETOSTATIC_POINT_CURRENT)
		KRATOS_REGISTER_IN_PYTHON_VARIABLE(MAGNETOSTATIC_SURFACE_CURRENT)
		KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(MAGNETIC_FIELD_INTENSITY)
		KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(MAGNETIC_FLUX_DENSITY)
		KRATOS_REGISTER_IN_PYTHON_VARIABLE(INFINIT_COEFFICIENT) 			 
  }  
  
}  // namespace Python.

}  // namespace Kratos. 

#endif // KRATOS_PYTHON defined

Python solver file: static_poisson_solver.py

The following file customise the Kratos solvers and strategies for our specific application. This file purpose is just to put together our variable names and solvers to be used, as follows (bold characters indicates the lines to be modified for each application):

#importing the Kratos Library
from Kratos import *
from KratosR1MagnetostaticApplication import * 

def AddVariables(model_part):
    model_part.AddNodalSolutionStepVariable(DISPLACEMENT);
    model_part.AddNodalSolutionStepVariable(MAGNETIC_PERMEABILITY);
    model_part.AddNodalSolutionStepVariable(MAGNETIC_FIELD_INTENSITY);
    model_part.AddNodalSolutionStepVariable(MAGNETIC_FLUX_DENSITY);

    model_part.AddNodalSolutionStepVariable(MAGNETOSTATIC_POTENTIAL);
    model_part.AddNodalSolutionStepVariable(MAGNETOSTATIC_POINT_CURRENT);
    model_part.AddNodalSolutionStepVariable(INFINIT_COEFFICIENT);
 
def AddDofs(model_part):
    for node in model_part.Nodes: 

        #adding dofs
        node.AddDof(MAGNETOSTATIC_POTENTIAL);

    print "variables for the Poisson solver added correctly"

class StaticPoissonSolver:
    #######################################################################
    def __init__(self,model_part,domain_size):

        self.model_part = model_part
        self.time_scheme = ResidualBasedIncrementalUpdateStaticScheme()

        #definition of the solvers
        self.poisson_linear_solver =  SkylineLUFactorizationSolver()
        
        #definition of the convergence criteria
        self.conv_criteria = DisplacementCriteria(1e-6,1e-9)
        
    #######################################################################
    def Initialize(self):
        #creating the solution strategy
        CalculateReactionFlag = False
        ReformDofSetAtEachStep = False
        MoveMeshFlag = True
        import strategy_python
        self.solver = strategy_python.SolvingStrategyPython(self.model_part,self.time_scheme,self.poisson_linear_solver,self.conv_criteria,CalculateReactionFlag,ReformDofSetAtEachStep,MoveMeshFlag)
      
                 
    #######################################################################   
    def Solve(self):
        (self.solver).Solve()

    #######################################################################   
    def SetEchoLevel(self,level):
        (self.solver).SetEchoLevel(level)

Customising the python applications interface: applications_interface.py

The python file for the applications (applications_interface.py) registers the applications' names and paths in order to load them from our specific simulation program. You have to edit this file and delete the applications_interface.pyc file.

Remember that our new application is called MagnetostaticApplication with a class named KratosR1MagnetostaticApplication in the path /kMagnetostatic. We need to add our specific application name and paths, as follows (note that the new lines are written in bold characters).

#path for applications s
import sys

Import_ALEApplication = False
Import_IncompressibleFluidApplication = False
Import_StructuralApplication = False
Import_ConvectionDiffusionApplication = False
Import_FSIApplication = False
Import_PFEMApplication = False
Import_ExternalSolversApplication = False
Import_ULFApplication = False
Import_MeshingApplication = False
Import_PoissonApplication = False
Import_ElectrostaticApplication = False
Import_MagnetostaticApplication = False


print "Applications Available:"
print "Import_ALEApplication: False"
print "Import_IncompressibleFluidApplication: False"
print "Import_StructuralApplication: False"
print "Import_ConvectionDiffusionApplication: False"
print "Import_FSIApplication: False"
print "Import_ExternalSolversApplication: False"
print "Import_ULFApplication: False"
print "Import_MeshingApplication: False"
print "Import_PoissonApplication: False"  
print "Import_ElectrostaticApplication: False"   
print "Import_MagnetostaticApplication: False"

def ImportApplications(kernel, applications_path):
    ##########################################################################
    ##importing the applications
    print "Applications Available:"
    print "Import_ALEApplication: "+str(Import_ALEApplication)
    print "Import_IncompressibleFluidApplication: "+str(Import_IncompressibleFluidApplication)
    print "Import_StructuralApplication: "+str(Import_StructuralApplication)
    print "Import_ConvectionDiffusionApplication: "+str(Import_ConvectionDiffusionApplication)
    print "Import_FSIApplication: "+str(Import_FSIApplication)
    print "Import_ExternalSolversApplication: "+str(Import_ExternalSolversApplication)
    print "Import_ULFApplication: "+str(Import_ULFApplication)
    print "Import_ULFApplication: "+str(Import_MeshingApplication)
    print "Import_PoissonApplication: "+str(Import_PoissonApplication)
    print "Import_ElectrostaticApplication: "+str(Import_ElectrostaticApplication)
    print "Import_MagnetostaticApplication: "+str(Import_MagnetostaticApplication)
    if(Import_ALEApplication == True):
        print "importing KratosR1ALEApplication ..."
        sys.path.append(applications_path + '/ALEapplication/python_scripts' )
        sys.path.append(applications_path + '/ALEapplication/Linux')
        from KratosR1ALEApplication import *
        ale_app = KratosR1ALEApplication()
        kernel.AddApplication(ale_app)
        print "KratosR1ALEApplication Succesfully imported"
        
    if(Import_IncompressibleFluidApplication == True):
        print "importing KratosR1IncompressibleFluidApplication ..."
        sys.path.append(applications_path + '/incompressible_fluid_application/python_scripts') 
        sys.path.append(applications_path + '/incompressible_fluid_application/Linux') 
        from KratosR1IncompressibleFluidApplication import *
        print "KratosR1IncompressibleFluidApplication lib loaded"
        incompressible_fluid_application = KratosR1IncompressibleFluidApplication()
        print "KratosR1IncompressibleFluidApplication application created"
        kernel.AddApplication(incompressible_fluid_application)
        print "KratosR1IncompressibleFluidApplication Succesfully imported"

    if(Import_StructuralApplication == True):
        print "importing KratosR1StructuralApplication ..."
        sys.path.append(applications_path + '/structural_application/python_scripts') 
        sys.path.append(applications_path + '/structural_application/Linux') 
        from KratosR1StructuralApplication import *
        structural_application = KratosR1StructuralApplication()
        kernel.AddApplication(structural_application)
        print "KratosR1StructuralApplication Succesfully imported"

    if(Import_ConvectionDiffusionApplication == True):
        print "importing KratosR1ConvectionDiffusionApplication ..."
        sys.path.append(applications_path + '/convection_diffusion_application/python_scripts') 
        sys.path.append(applications_path + '/convection_diffusion_application/Linux') 
        from KratosR1ConvectionDiffusionApplication import *
        convection_diffusion_application = KratosR1ConvectionDiffusionApplication()
        kernel.AddApplication(convection_diffusion_application)
        print "KratosR1ConvectionDiffusionApplication Succesfully imported" 

    if(Import_FSIApplication == True):
        print "importing FSIapplication ..."
        sys.path.append(applications_path + '/FSIapplication/python_scripts') 
        sys.path.append(applications_path + '/FSIapplication/Linux') 
        from KratosR1FSIApplication import *
        fsi_application = KratosR1FSIApplication()
        kernel.AddApplication(fsi_application)
        print "FSIapplication Succesfully imported"

    if(Import_PFEMApplication == True):
        print "importing KratosR1PFEMApplication ..."
        sys.path.append(applications_path + '/PFEMapplication/python_scripts') 
        sys.path.append(applications_path + '/PFEMapplication/Linux') 
        from KratosR1PFEMApplication import *
        pfkElectrostatic = KratosR1PFEMApplication()
        kernel.AddApplication(pfkElectrostatic)
        print "KratosR1PFEMApplication Succesfully imported"
	
   if(Import_ExternalSolversApplication == True): 
        print "importing KratosExternalSolversApplication ..."
        sys.path.append(applications_path + '/ExternalSolversApplication/python_scripts')
        sys.path.append(applications_path + '/ExternalSolversApplication/Linux')
        from KratosR1ExternalSolversApplication import *
        external_solvers_application = KratosR1ExternalSolversApplication()
        kernel.AddApplication(external_solvers_application)
        print "KratosExternalSolversApplication sucessfully imported"
 	
    if(Import_ULFApplication == True):
        print "importing KratosR1ULFApplication ..."
        sys.path.append(applications_path + '/ULFapplication/python_scripts')
        sys.path.append(applications_path + '/ULFapplication/Linux')
        from KratosR1ULFApplication import *
        ulf_application = KratosR1ULFApplication()
        kernel.AddApplication(ulf_application)
        print "KratosULFApplication sucessfully imported"

    if(Import_MeshingApplication == True):
        print "importing KratosR1MeshingApplication ..."
        sys.path.append(applications_path + '/MeshingApplication/python_scripts')
        from KratosR1MeshingApplication import *
        meshing_application = KratosR1MeshingApplication()
        kernel.AddApplication(meshing_application)
        print "KratosMeshingApplication sucessfully imported" 
       
    if(Import_PoissonApplication == True):
        print "importing KratosR1PoissonApplication ..."
        sys.path.append(applications_path + '/kPoisson/python_scripts')
        from KratosR1PoissonApplication import *
        kPoisson = KratosR1PoissonApplication()
        kernel.AddApplication(kPoisson)
        print "Kratos PoissonApplication sucessfully imported"
    if(Import_ElectrostaticApplication == True):
        print "importing KratosR1ElectrostaticApplication ..."
        sys.path.append(applications_path + '/kElectrostatic/python_scripts')
        from KratosR1ElectrostaticApplication import *
        kElectrostatic = KratosR1ElectrostaticApplication()
        kernel.AddApplication(kElectrostatic)
        print "Kratos ElectromagnecticApplication1 sucessfully imported"
    if(Import_MagnetostaticApplication == True):
        print "importing KratosR1magnetostaticApplication ..."
        sys.path.append(applications_path + '/kMagnetostatic/python_scripts')
        from KratosR1MagnetostaticApplication import *
        kMagnetostatic = KratosR1MagnetostaticApplication()
        kernel.AddApplication(kMagnetostatic)
        print "Kratos ElectromagnecticApplication2 sucessfully imported"


    ##########################################################################
    ##dynamic renumbering of variables to ensure the consistency
    kernel.Initialize()
    if(Import_ALEApplication == True):
        kernel.InitializeApplication(ale_app);
    if(Import_IncompressibleFluidApplication == True):
        kernel.InitializeApplication(incompressible_fluid_application);    
    if(Import_StructuralApplication == True):
        kernel.InitializeApplication(structural_application);    
    if(Import_ConvectionDiffusionApplication == True):
        kernel.InitializeApplication(convection_diffusion_application); 
    if(Import_FSIApplication == True):
        kernel.InitializeApplication(fsi_application); 
    if(Import_PFEMApplication == True):
        kernel.InitializeApplication(pfkElectrostatic); 
    if(Import_ExternalSolversApplication == True):
        kernel.InitializeApplication(external_solvers_application);
    if(Import_ULFApplication == True):
        kernel.InitializeApplication(ulf_application);
    if(Import_MeshingApplication == True):
        kernel.InitializeApplication(meshing_application);
    if(Import_PoissonApplication == True):
        kernel.InitializeApplication(kPoisson);
    if(Import_ElectrostaticApplication == True):
        kernel.InitializeApplication(kElectrostatic);
    if(Import_MagnetostaticApplication == True):
        kernel.InitializeApplication(kMagnetostatic);

Customising the main Kratos python compiling file: Jamroot

The last file to modify is the python guide to compile Kratos, the Jamroot file in the Kratos root. The only lines to include are those related to your application, that is, at the end of the file, the list of applications included in the compilation. Note that if you don't want to load any specific application, you can remove it from this file or also just simply comment it using the "#" character:

using gcc ;
using intel : : : <cxxflags>"-fPIC -ansi -funroll-loops -cxxlib-gcc -openmp -wd654 -wd10010" <cflags>"-fPIC -funroll-loops -cxxlib-gcc -openmp -wd654 -wd10010" ;
using msvc ;
using python ; 


#################################################################################
## defining "common includes" and external libraries
path-constant TOP : . ;

#path to the boost library -- FUNDAMENTAL --- ATTENTION: it is IMPORTANT to set to the directory FROM WHICH the boost was installed
path-constant BOOST_LIB_DIR :  /usr/lib/ ; 
path-constant BOOST_INCLUDE_DIR :  /usr/include/ ; 

project KratosProject 
	:
	#############################################################################
	############### TO BE CUSTOMARIZED -- LINUX VERSION EXAMPLE!! ###############
	##requirements <include>/usr/include/boost         #to be customarized 
	##		 <include>/usr/include/python2.5/        #to be customarized 
       ##     	<include>$(TOP)/kratos
	##	     <include>$(TOP)/external_libraries
	#############################################################################

	#############################################################################
	############### TO BE CUSTOMARIZED -- WINDOWS VERSION EXAMPLE!! ###############
	############### TO BE CUSTOMIZED -- WINDOWS VERSION EXAMPLE!! ###############
	requirements <include>"D:/kratos2009/kratos/external_libraries/boost/boost_1_39"    #to be CUSTOMIZED
			<include>"D:/Python26/include"                                  #to be CUSTOMIZED 
			<include>$(TOP)/kratos
			<include>$(TOP)/external_libraries
	#############################################################################	

		     ##omptl - necessary for parallelism
		     <include>$(TOP)/external_libraries/omptl
			
			#basic configurations
		     <threading>multi
		     <define>NDEBUG

			 #compiler settings - can be customarized by the user
			 #WARNING -fPIC is NEEDED to compile on 64bit systems - it has to be specified here in order to include it in the 
			 #kratos "static" library
			 <warnings>on

			 #gcc settings
			<toolset>gcc:<cflags>"-fPIC -funroll-loops" ##settings for external libraries
 			<toolset>gcc:<cxxflags>"-fPIC -ansi -funroll-loops -ffast-math" 

			#msvc settings
			<toolset>msvc:<linkflags>"/NODEFAULTLIB:libcmt"
			<toolset>msvc:<cxxflags>"/D_SCL_SECURE_NO_DEPRECATE  /wd4335"

			#intel settings
		##	<toolset>intel:<cxxflags>"-fPIC -ansi -funroll-loops -ffast-math" 
	: 
		     default-build release
	;

#################################################################################
## defining "common external libraries" 
## the user should adapt this depending on the installations directories on his system

#############################################################################
############### TO BE CUSTOMARIZED -- LINUX VERSION EXAMPLE!! ###############
##lib pythonlib : : <name>python2.5 ; 
##lib boost_python_lib : : <variant>debug <name>boost_python-mt-d ;   
##lib boost_python_lib : : <variant>release <name>boost_python-mt ;   
##lib boost_python_lib : : <variant>debug <name>boost_python-gcc-mt-d-1_34_1 ;   
##lib boost_python_lib : : <variant>release <name>boost_python-gcc-mt-1_34_1 ;   
##lib gidpost : : <name>gidpost <search>$(TOP)/external_libraries/gidpost/unix/release ;
#############################################################################

#############################################################################
############### TO BE CUSTOMARIZED -- WINDOWS VERSION EXAMPLE!! ###############
lib pythonlib : : <name>python26 <search>"D:/Python26/libs"  ; 
lib boost_python_lib : : <variant>release <name>boost_python-vc80-mt-1_39 <search>"D:/kratos2009/kratos/external_libraries/boost/boost_1_39/lib" ;   
lib boost_python_lib : : <variant>debug <name>boost_python-vc80-mt-gd-1_39 <search>"D:/kratos2009/kratos/external_libraries/boost/boost_1_39/lib" ; 
lib gidpost : : <name>gidpost <search>$(TOP)/external_libraries/gidpost/win/Release/ ; 
#############################################################################

#intel omp library...
lib intelomp  : : <name>guide  ; 

#ATTENTION: "this requires adding threading=multi to the bjam call"
alias libomp : intelomp : <toolset>intel ;
alias libomp : : <toolset>gcc ;
alias libomp : : <toolset>msvc ;


#################################################################################
# IN PRINCIPLE THIS SHOULD REQUIRE NO CUSTOMARIZATION .. apart for compiling new applications
## defining "ids" for the different projects
use-project /kratos-prj : . ;

##kratos base library and python interfaces
use-project /kratos-prj/kratos : kratos ; 

##applications included in the compilation
use-project /kratos-prj/PFEMapplication : $(TOP)/applications/PFEMapplication ;
use-project /kratos-prj/incompressible_fluid_application : $(TOP)/applications/incompressible_fluid_application ;
use-project /kratos-prj/structural_application : $(TOP)/applications/structural_application ;
use-project /kratos-prj/convection_diffusion_application : $(TOP)/applications/convection_diffusion_application ;
use-project /kratos-prj/ExternalSolversApplication : $(TOP)/applications/ExternalSolversApplication ;
use-project /kratos-prj/ULFapplication : $(TOP)/applications/ULFapplication ;
use-project /kratos-prj/ALEapplication : $(TOP)/applications/ALEapplication ;
use-project /kratos-prj/FSIapplication : $(TOP)/applications/FSIapplication ;
use-project /kratos-prj/kPoisson : $(TOP)/applications/kPoisson ;
use-project /kratos-prj/kElectrostatic : $(TOP)/applications/kElectrostatic ;
use-project /kratos-prj/kMagnetostatic : $(TOP)/applications/kMagnetostatic ;


alias libkratos_static : /kratos-prj/kratos//libkratos/<link>static ;

#################################################################################
## installation
alias install : 
		/kratos-prj//kratos 
		/kratos-prj/PFEMapplication//install
		/kratos-prj/incompressible_fluid_application//install
		/kratos-prj/structural_application//install
		/kratos-prj/convection_diffusion_application//install
# 		/kratos-prj/ExternalSolversApplication//install
		/kratos-prj/ULFapplication//install
		/kratos-prj/ALEapplication//install
#		/kratos-prj/FSIapplication//install
		/kratos-prj/kPoisson//install
		/kratos-prj/kElectrostatic//install

/kratos-prj/kMagnetostatic//install

		;

ECHO $(TOP) ;

Rebuilding Kratos

Now it is the moment to compile all our new files. It's expected to find minor errors, and we will include in this section the most frequent problems found. Please, use the discussion tab to include your questions or difficulties.

Info_icon.gif Things to do:

  • Include the most frequent compilation errors.

One typical error is to use something not yet undefined in Kratos. The most evident case is the variables' name.

Check the Global files section for that.

Personal tools
Categories