ElmerFoamFSI  2.0
ElmerFoamFSI is fluid-solid interaction simulation application built up from OpenFOAM CFD and Elmer CSM coupled through the IMPACT multiphysics software integration infrastructure.
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Groups Pages
icoFoamModule.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration |
5  \\ / A nd | For copyright notice see file Copyright
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation, either version 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  icoFoam
26 
27 Description
28  Transient solver for incompressible, laminar flow of Newtonian fluids.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "fvCFD.H"
33 #include "com.h"
34 #include "com_devel.hpp"
35 
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 #include <string>
47 #include <cstring>
48 #include <iostream>
49 #include <sstream>
50 #include <iomanip>
51 #include <vector>
52 
53 
54 COM_EXTERN_MODULE( IcoFoamModule);
55 
56 
57 namespace IcoFoamMod {
58 
59  class IcoFoamModule : public COM_Object {
60  public:
63 
69  virtual ~IcoFoamModule()
70  {
71  if(!other_window_name.empty()){
72  int other_window_handle = COM_get_window_handle(other_window_name.c_str());
73  if(other_window_handle > 0)
74  COM_UNLOAD_MODULE_STATIC_DYNAMIC(COMTESTMOD,other_window_name.c_str());
75  }
76  if(!fortran_window_name.empty()){
77  int fortran_window_handle = COM_get_window_handle(fortran_window_name.c_str());
78  if(fortran_window_handle > 0)
79  COM_UNLOAD_MODULE_STATIC_DYNAMIC(COMFTESTMOD,fortran_window_name.c_str());
80  }
81  };
82 
83 #include "icoFoamHeader.H"
84 
85  int IcoFoamModuleFunction(int *pargc, void **pargv)
86  {
87  int argc = *pargc;
88  char** argv = (char**)(pargv);
89 
90  icoFoamMain(argc, argv);
91 
92 
93  return 0;
94  }
95 
100  static void Load(const std::string &name){
101  std::cout << "Loading IcoFoamModule with name " << name
102  << "." << std::endl;
103 
104  IcoFoamModule *module_pointer = new IcoFoamModule();
105  COM_new_window(name, MPI_COMM_NULL);
106  module_pointer->my_window_name = name;
107  std::string global_name(name+".global");
108  COM_new_dataitem(global_name.c_str(),'w',COM_VOID,1,"");
109  COM_set_object(global_name.c_str(),0,module_pointer);
110 
111 
112  std::vector<COM_Type> types(13,COM_INT);
113 
114  types[0] = COM_RAWDATA;
115  types[2] = COM_VOID;
116  COM_set_member_function( (name+".IcoFoamModuleFunction").c_str(),
117  (Member_func_ptr)(&IcoFoamModule::IcoFoamModuleFunction),
118  global_name.c_str(), "bii", &types[0]);
119 
120 
121 
122  COM_window_init_done(name);
123  }
124 
125 
130  static void Unload(const std::string &name){
131  std::cout << "Unloading IcoFoamModule with name " << name
132  << "." << std::endl;
133  IcoFoamModule *module_pointer = NULL;
134  std::string global_name(name+".global");
135  COM_get_object(global_name.c_str(),0,&module_pointer);
136  COM_assertion_msg( module_pointer->validate_object()==0, "Invalid object");
137  delete module_pointer;
138  COM_delete_window(std::string(name));
139  }
140 
141  private:
142  std::vector<int> dataArray;
143  std::string my_window_name;
144  std::string other_window_name;
145  std::string fortran_window_name;
146  };
147 }
148 
152 extern "C" void IcoFoamModule_load_module( const char *name) {
154 }
158 extern "C" void IcoFoamModule_unload_module( const char *name){
160 }
161 
162 
163 
164 
165 
166 // ************************************************************************* //
std::vector< int > dataArray
std::string other_window_name
Tracks this window name.
IcoFoamModule()
Default constructor.
Definition: icoFoamModule.C:62
void IcoFoamModule_unload_module(const char *name)
C/C++ bindings to unload IcoFoamModule.
std::string fortran_window_name
Tracks this external window&#39;s name.
int IcoFoamModuleFunction(int *pargc, void **pargv)
Definition: icoFoamModule.C:85
virtual ~IcoFoamModule()
Destructor.
Definition: icoFoamModule.C:69
void IcoFoamModule_load_module(const char *name)
C/C++ bindings to load IcoFoamModule.
static void Unload(const std::string &name)
Unloads the IcoFoamModule.
COM_EXTERN_MODULE(OpenFoamFSI)
static void Load(const std::string &name)
&quot;Loads&quot; IcoFoamModule