v0.10.0
optimal_mass_transport.cpp
Go to the documentation of this file.
1 /** \file optimal_mass_transport.cpp
2  * \ingroup optimal_mass_transport
3  *
4  * \brief optimal mass transport
5  *
6  */
7 
8 /* This file is part of MoFEM.
9  * MoFEM is free software: you can redistribute it and/or modify it under
10  * the terms of the GNU Lesser General Public License as published by the
11  * Free Software Foundation, either version 3 of the License, or (at your
12  * option) any later version.
13  *
14  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
21 
22 #include <BasicFiniteElements.hpp>
23 using namespace MoFEM;
24 #include <OptimalMassTransport.hpp>
25 
26 static char help[] = "...\n\n";
27 
28 int main(int argc, char *argv[]) {
29 
30 
31 
32 
33  PetscInitialize(&argc,&argv,(char *)0,help);
34 
35  moab::Core mb_instance;
36  moab::Interface& moab = mb_instance;
37 
38  ParallelComm* pcomm = ParallelComm::get_pcomm(&moab,MYPCOMM_INDEX);
39  if(pcomm == NULL) pcomm = new ParallelComm(&moab,PETSC_COMM_WORLD);
40 
41  //Read parameters from line command
42  PetscBool flg_file;
43  char mesh_file_name[255];
44  PetscInt order = 2;
45  PetscBool is_partitioned = PETSC_FALSE;
46 
47  ierr = PetscOptionsBegin(
48  PETSC_COMM_WORLD,"","Shell prism configure","none"
49  ); CHKERRQ(ierr);
50  ierr = PetscOptionsString(
51  "-my_file",
52  "mesh file name","", "mesh.h5m",mesh_file_name, 255, &flg_file
53  ); CHKERRQ(ierr);
54  ierr = PetscOptionsInt(
55  "-my_order",
56  "default approximation order",
57  "",order,&order,PETSC_NULL
58  ); CHKERRQ(ierr);
59  ierr = PetscOptionsBool(
60  "-my_is_partitioned",
61  "set if mesh is partitioned (this result that each process keeps only part of the mesh)",
62  "",PETSC_FALSE,&is_partitioned,PETSC_NULL
63  ); CHKERRQ(ierr);
64  ierr = PetscOptionsEnd(); CHKERRQ(ierr);
65 
66  if(is_partitioned == PETSC_TRUE) {
67  //Read mesh to MOAB
68  const char *option;
69  option = "PARALLEL=READ_PART;"
70  "PARALLEL_RESOLVE_SHARED_ENTS;"
71  "PARTITION=PARALLEL_PARTITION;";
72  rval = moab.load_file(mesh_file_name, 0, option); CHKERRQ_MOAB(rval);
73  } else {
74  const char *option;
75  option = "";
76  rval = moab.load_file(mesh_file_name, 0, option); CHKERRQ_MOAB(rval);
77  }
78 
79  //Create mofem interface
80  MoFEM::Core core(moab);
81  MoFEM::Interface& m_field = core;
82 
83  OptimalMassTransport opt(m_field);
84  opt.blockData.oRder = order;
85  ierr = opt.printGMeshMeshsets(); CHKERRQ(ierr);
86  // ierr = opt.getNaturalBc(); CHKERRQ(ierr);
87  // ierr = opt.getEssentialBc(); CHKERRQ(ierr);
88  // ierr = opt.createFields(); CHKERRQ(ierr);
89  // ierr = opt.createElements(); CHKERRQ(ierr);
90  // ierr = opt.createProblem(); CHKERRQ(ierr);
91  // ierr = opt.solveProblem(); CHKERRQ(ierr);
92  // ierr = opt.postProcessResults(); CHKERRQ(ierr);
93  // ierr = opt.destroyProblem(); CHKERRQ(ierr);
94 
95  ierr = PetscFinalize(); CHKERRQ(ierr);
96 
97  return 0;
98 }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:523
Deprecated interface functions.
CoreTmp< 0 > Core
Definition: Core.hpp:1129
int main(int argc, char *argv[])
Header file for Implementation of optimal mass transport See details in .
PetscErrorCode printGMeshMeshsets()
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
char mesh_file_name[255]
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:85
static char help[]
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
constexpr int order
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:292
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1943
Core (interface) class.
Definition: Core.hpp:77