| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// NOX: An Object-Oriented Nonlinear Solver Package |
| 4 |
// |
| 5 |
// Copyright 2002 NTESS and the NOX contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef NOX_MULTIPHYSICS_MATLAB_INTERFACE_H |
| 11 |
#define NOX_MULTIPHYSICS_MATLAB_INTERFACE_H |
| 12 |
|
| 13 |
#include "NOX_Matlab_Interface.H" //base class |
| 14 |
|
| 15 |
#ifdef HAVE_MATLAB |
| 16 |
|
| 17 |
//----------------------------------------------------------------------------- |
| 18 |
|
| 19 |
// Forward declarations |
| 20 |
class Problem_Manager; |
| 21 |
|
| 22 |
// This is a new class that may evantually get moved into NOX. For now, |
| 23 |
// this is simply used as a testbed for driving NOX using Matlab |
| 24 |
|
| 25 |
class Coupling_Matlab_Interface : public Matlab_Interface |
| 26 |
{ |
| 27 |
public: |
| 28 |
|
| 29 |
// A base class for Matlab interface commands to NOX |
| 30 |
class CommandBase : public Matlab_Interface::CommandBase |
| 31 |
{ |
| 32 |
|
| 33 |
public: |
| 34 |
|
| 35 |
CommandBase( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 36 |
Problem_Manager & ); |
| 37 |
|
| 38 |
// methods |
| 39 |
|
| 40 |
virtual bool doCommand( std::string ) = 0 ; |
| 41 |
|
| 42 |
|
| 43 |
// Get the Coupling solver |
| 44 |
const Problem_Manager & getCoupler() |
| 45 |
{ return problemManager; } |
| 46 |
|
| 47 |
protected: |
| 48 |
|
| 49 |
// methods |
| 50 |
|
| 51 |
virtual ~CommandBase() { }; |
| 52 |
|
| 53 |
// data |
| 54 |
|
| 55 |
Problem_Manager & problemManager; |
| 56 |
|
| 57 |
}; |
| 58 |
|
| 59 |
// Derived classes that represent individual commands |
| 60 |
|
| 61 |
class CMD_problemSummary : public CommandBase |
| 62 |
{ |
| 63 |
|
| 64 |
public: |
| 65 |
|
| 66 |
CMD_problemSummary( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 67 |
Problem_Manager & problemManager_ ) : |
| 68 |
CommandBase( engine_, problemManager_ ) |
| 69 |
{ |
| 70 |
myCategory = QUERY; |
| 71 |
command = "problemSummary" ; |
| 72 |
description = " - (Coupling) Summarize coupled problems" ; |
| 73 |
} |
| 74 |
|
| 75 |
virtual bool doCommand( std::string ); |
| 76 |
}; |
| 77 |
|
| 78 |
class CMD_showAllValid : public CommandBase |
| 79 |
{ |
| 80 |
|
| 81 |
public: |
| 82 |
|
| 83 |
CMD_showAllValid( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 84 |
Problem_Manager & solver_ ) : |
| 85 |
CommandBase( engine_, solver_ ) |
| 86 |
{ |
| 87 |
myCategory = QUERY; |
| 88 |
command = "showAllValid" ; |
| 89 |
description = " - (Coupling) Show valid status of all groups" ; |
| 90 |
} |
| 91 |
|
| 92 |
virtual bool doCommand( std::string ); |
| 93 |
}; |
| 94 |
|
| 95 |
class CMD_compPreconditioner : public CommandBase |
| 96 |
{ |
| 97 |
|
| 98 |
public: |
| 99 |
|
| 100 |
CMD_compPreconditioner( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 101 |
Problem_Manager & solver_ ) : |
| 102 |
CommandBase( engine_, solver_ ) |
| 103 |
{ |
| 104 |
myCategory = GROUP_COMPUTE; |
| 105 |
command = "compPreconditioner" ; |
| 106 |
description = " - (Coupling) Compute the coupling Preconditioner matrix" ; |
| 107 |
} |
| 108 |
|
| 109 |
virtual bool doCommand( std::string ); |
| 110 |
}; |
| 111 |
|
| 112 |
class CMD_compJac : public CommandBase |
| 113 |
{ |
| 114 |
|
| 115 |
public: |
| 116 |
|
| 117 |
CMD_compJac( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 118 |
Problem_Manager & problemManager_ ) : |
| 119 |
CommandBase( engine_, problemManager_ ) |
| 120 |
{ |
| 121 |
myCategory = GROUP_COMPUTE; |
| 122 |
command = "compJac[" ; |
| 123 |
description = " - (Coupling) Compute Block Jacobian (i, j)" ; |
| 124 |
} |
| 125 |
|
| 126 |
virtual bool doCommand( std::string ); |
| 127 |
}; |
| 128 |
|
| 129 |
class CMD_setXvec : public CommandBase |
| 130 |
{ |
| 131 |
|
| 132 |
public: |
| 133 |
|
| 134 |
CMD_setXvec( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 135 |
Problem_Manager & problemManager_ ) : |
| 136 |
CommandBase( engine_, problemManager_ ) |
| 137 |
{ |
| 138 |
myCategory = GROUP_SET; |
| 139 |
command = "setSoln[" ; |
| 140 |
description = " - (Coupling) Set a solution vector of problem i" ; |
| 141 |
} |
| 142 |
|
| 143 |
virtual bool doCommand( std::string ); |
| 144 |
}; |
| 145 |
|
| 146 |
class CMD_compRes : public CommandBase |
| 147 |
{ |
| 148 |
|
| 149 |
public: |
| 150 |
|
| 151 |
CMD_compRes( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 152 |
Problem_Manager & problemManager_ ) : |
| 153 |
CommandBase( engine_, problemManager_ ) |
| 154 |
{ |
| 155 |
myCategory = GROUP_COMPUTE; |
| 156 |
command = "compRes[" ; |
| 157 |
description = " - (Coupling) Compute Residual for problem i" ; |
| 158 |
} |
| 159 |
|
| 160 |
virtual bool doCommand( std::string ); |
| 161 |
}; |
| 162 |
|
| 163 |
class CMD_syncAllGroupX : public CommandBase |
| 164 |
{ |
| 165 |
|
| 166 |
public: |
| 167 |
|
| 168 |
CMD_syncAllGroupX( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 169 |
Problem_Manager & solver_ ) : |
| 170 |
CommandBase( engine_, solver_ ) |
| 171 |
{ |
| 172 |
myCategory = GROUP_SET; |
| 173 |
command = "syncGroupsX" ; |
| 174 |
description = " - (Coupling) Copy pieces of coupling Group solution into each problem's group solution." ; |
| 175 |
} |
| 176 |
|
| 177 |
virtual bool doCommand( std::string ); |
| 178 |
}; |
| 179 |
|
| 180 |
class CMD_doXfers : public CommandBase |
| 181 |
{ |
| 182 |
|
| 183 |
public: |
| 184 |
|
| 185 |
CMD_doXfers( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 186 |
Problem_Manager & problemManager_ ) : |
| 187 |
CommandBase( engine_, problemManager_ ) |
| 188 |
{ |
| 189 |
myCategory = CALLBACK_FUN; |
| 190 |
command = "doXfers" ; |
| 191 |
description = " - (Coupling) Do all registered transfers of data" ; |
| 192 |
} |
| 193 |
|
| 194 |
virtual bool doCommand( std::string ); |
| 195 |
}; |
| 196 |
|
| 197 |
class CMD_getAllX : public CommandBase |
| 198 |
{ |
| 199 |
|
| 200 |
public: |
| 201 |
|
| 202 |
CMD_getAllX( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 203 |
Problem_Manager & problemManager_ ) : |
| 204 |
CommandBase( engine_, problemManager_ ) |
| 205 |
{ |
| 206 |
myCategory = GROUP_GET; |
| 207 |
command = "getAllX" ; |
| 208 |
description = " - (Coupling) Get All Problem Solutions" ; |
| 209 |
} |
| 210 |
|
| 211 |
virtual bool doCommand( std::string ); |
| 212 |
}; |
| 213 |
|
| 214 |
class CMD_getJac : public CommandBase |
| 215 |
{ |
| 216 |
|
| 217 |
public: |
| 218 |
|
| 219 |
CMD_getJac( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 220 |
Problem_Manager & problemManager_ ) : |
| 221 |
CommandBase( engine_, problemManager_ ) |
| 222 |
{ |
| 223 |
myCategory = GROUP_GET; |
| 224 |
command = "getJac[" ; |
| 225 |
description = " - (Coupling) Get Block Jacobian [i j]" ; |
| 226 |
} |
| 227 |
|
| 228 |
virtual bool doCommand( std::string ); |
| 229 |
}; |
| 230 |
|
| 231 |
class CMD_getAllJac : public CommandBase |
| 232 |
{ |
| 233 |
|
| 234 |
public: |
| 235 |
|
| 236 |
CMD_getAllJac( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 237 |
Problem_Manager & problemManager_ ) : |
| 238 |
CommandBase( engine_, problemManager_ ) |
| 239 |
{ |
| 240 |
myCategory = GROUP_GET; |
| 241 |
command = "getAllJac" ; |
| 242 |
description = " - (Coupling) Get All Block Jacobians" ; |
| 243 |
} |
| 244 |
|
| 245 |
virtual bool doCommand( std::string ); |
| 246 |
}; |
| 247 |
|
| 248 |
class CMD_getRes : public CommandBase |
| 249 |
{ |
| 250 |
|
| 251 |
public: |
| 252 |
|
| 253 |
CMD_getRes( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 254 |
Problem_Manager & problemManager_ ) : |
| 255 |
CommandBase( engine_, problemManager_ ) |
| 256 |
{ |
| 257 |
myCategory = GROUP_GET; |
| 258 |
command = "getRes[" ; |
| 259 |
description = " - (Coupling) Get Residual for Problem [i]" ; |
| 260 |
} |
| 261 |
|
| 262 |
virtual bool doCommand( std::string ); |
| 263 |
}; |
| 264 |
|
| 265 |
class CMD_getAllRes : public CommandBase |
| 266 |
{ |
| 267 |
|
| 268 |
public: |
| 269 |
|
| 270 |
CMD_getAllRes( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 271 |
Problem_Manager & problemManager_ ) : |
| 272 |
CommandBase( engine_, problemManager_ ) |
| 273 |
{ |
| 274 |
myCategory = GROUP_GET; |
| 275 |
command = "getAllRes" ; |
| 276 |
description = " - (Coupling) Get All Problem Residuals" ; |
| 277 |
} |
| 278 |
|
| 279 |
virtual bool doCommand( std::string ); |
| 280 |
}; |
| 281 |
|
| 282 |
class CMD_getPrecMatrix : public CommandBase |
| 283 |
{ |
| 284 |
|
| 285 |
public: |
| 286 |
|
| 287 |
CMD_getPrecMatrix( EpetraExt::EpetraExt_MatlabEngine & engine_, |
| 288 |
Problem_Manager & solver_ ) : |
| 289 |
CommandBase( engine_, solver_ ) |
| 290 |
{ |
| 291 |
myCategory = GROUP_GET; |
| 292 |
command = "getPrecMatrix" ; |
| 293 |
description = " - (Coupling) Get the coupling Preconditioner matrix" ; |
| 294 |
} |
| 295 |
|
| 296 |
virtual bool doCommand( std::string ); |
| 297 |
}; |
| 298 |
|
| 299 |
Coupling_Matlab_Interface(Problem_Manager & manager); |
| 300 |
|
| 301 |
virtual ~Coupling_Matlab_Interface() { }; |
| 302 |
|
| 303 |
protected: |
| 304 |
|
| 305 |
// Methods |
| 306 |
|
| 307 |
// Data |
| 308 |
|
| 309 |
Problem_Manager & problemManager; |
| 310 |
}; |
| 311 |
|
| 312 |
#endif |
| 313 |
#endif // NOX_MULTIPHYSICS_MATLAB_INTERFACE_H |