/* Fesslix - Stochastic Analysis
 * Copyright (C) 2010-2016 Wolfgang Betz
 *
 * Fesslix is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Fesslix is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Fesslix.  If not, see <http://www.gnu.org/licenses/>. 
 */


#define VERSION_REV 7
#define VERSION_DATE "2016-06-13"

#if defined(_MSC_VER)
  #include "flxlibfem_export.h"
#else
  #define FLXLIBFEM_EXPORT
#endif

#ifdef __WINDOWS__
  #pragma comment(lib, "flxkernel")
#endif

#include "flxlibs_interface.h"
#include "flxobjfem.h"
#include "flxobjrf.h"

flxlibs_interface flx_iface;


extern "C" FLXLIBFEM_EXPORT void flxlib_init( FlxObjectReadBox* objReadBox, FlxData* dataBox ) {
  GlobalVar.slog(4) << "  FEM-library - Version " << VERSION_REV << " (" << VERSION_DATE << ")" << std::endl;
  flx_iface.set_boxes(objReadBox,&(dataBox->FunBox));
  
  // FEM-Objects
    flx_iface.add_obj("node", new FlxObjReadNode());
    flx_iface.add_obj("edge", new FlxObjReadEdge());
    flx_iface.add_obj("face", new FlxObjReadFace());
    flx_iface.add_obj("box", new FlxObjReadGeoBox());
    flx_iface.add_obj("isomat", new FlxObjReadIsoMaterial());
    flx_iface.add_obj("crosssec", new FlxObjReadCrossSec());
    flx_iface.add_obj("loadcase", new FlxObjReadLoadCase());
    flx_iface.add_obj("nload", new FlxObjReadNLoad());
    flx_iface.add_obj("eload", new FlxObjReadELoad());
    flx_iface.add_obj("eltruss", new FlxObjReadElTruss());
    flx_iface.add_obj("elbeam", new FlxObjReadElBeam());
    flx_iface.add_obj("elplanestr", new FlxObjReadElPlaneStr());
    flx_iface.add_obj("fem", new FlxObjReadControlFEM());
    flx_iface.add_obj("elplot", new FlxObjReadElPlot());
    flx_iface.add_obj("data_import", new FlxObjReadDataImport());
    flx_iface.add_obj("print_hlegendrepoly", new FlxObjReadPrintHLegendrePoly());
    flx_iface.add_obj("print_hgegenbauerpoly", new FlxObjReadPrintHGegenbauerPoly());
  
  // FEM functions
    flx_iface.add_fun("nodeu",new FunReadNodeU() );
    flx_iface.add_fun("nodef",new FunReadNodeF() );
    flx_iface.add_fun("elinfo",new FunReadFEMelInfo() );
    flx_iface.add_fun("geocalc",new FunReadGeoCalc() );
    flx_iface.add_fun("geotimer",new FunReadGeoTimer() );
    flx_iface.add_fun("geointeg",new FunReadGeoInteg() );
    flx_iface.add_fun("hlegendrepoly",new FunReadFunHLegendrePoly() );
    flx_iface.add_fun("hgegenbauerpoly", new FunReadFunHGegenbauerPoly() );
    FlxBoxBaseR::set_GI(&(dataBox->GaussInt));
    flxElement_base::set_Const();
    flxElement_1D_base::set_Const();
    flxElement_KL_base::set_Const();
    flxPoint::set_Const(dataBox->ConstantBox);
    flxDOFe::set_Const(dataBox->ConstantBox);
    flxDOFf::set_Const(dataBox->ConstantBox);
    flxDomain_base::set_Const(dataBox->ConstantBox);
    FlxRandomField_base::set_Const();
    if (FEMbox_get()) throw FlxException_Crude("FlxCreateObjReaders_FEM::createFunReaders");
    FEMbox_get() = new flxFEM(&(dataBox->ConstantBox));
    FlxRandomField_base::data = dataBox;
 
  // RF objects
    flx_iface.add_obj("mtxconst_rf_elidvec", new FlxObjReadMtxConstRfElIdVec());
    flx_iface.add_obj("rf_new", new FlxObjReadRndRfCreate());
    flx_iface.add_obj("rf_elset", new FlxObjReadRndRfElSet());
    flx_iface.add_obj("rf_solve", new FlxObjReadRndRfSolve());
    flx_iface.add_obj("rf_err", new FlxObjReadRndRfErr());
    flx_iface.add_obj("rf_plot", new FlxObjReadRndRfPlot());
    flx_iface.add_obj("rf_plotcov", new FlxObjReadRndRfPlotCov());
  
  // RF functions
    flx_iface.add_fun("rf_eigenvalue",new FunReadFunFunRFeigenvalue() );
    flx_iface.add_fun("rf", new FunReadFunRF() );
    flx_iface.add_fun("rf_err", new FunReadFunRFerr() );
    
}

extern "C" FLXLIBFEM_EXPORT void flxlib_close() {
  flx_iface.free_memory();
}


